开发者

ASP.NET [How to check if SqlDataSource1 is empty]

开发者 https://www.devze.com 2022-12-17 20:13 出处:网络
I make SqlDataSource1.DataBind(); with some parameters on button click, then I\'m working with a Grid onDataBound();

I make SqlDataSource1.DataBind(); with some parameters on button click,

then I'm working with a Grid onDataBound();

but if my SqlDataSource1 returns empty data I've got an error even if 开发者_JS百科I'm trying to check if (GridView2.HeaderRow.Cells.Count != 0) so I guess I need to check it on SqlDataSource1 someway.

Question : How ?

Thank you.


GridView2.HeaderRow is null when when the data source is null so you could try checking if GridView2.HeaderRow = null


I would check GridView2.Rows.Count instead. Maybe there are no HeaderRow cells when the data source is empty.

0

精彩评论

暂无评论...
验证码 换一张
取 消