0

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 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.

0

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

I'm not sure I have access to rows - count when datasource is empty, but previous answer works for sure.
Row count should be zero after DataBind() on the GridView, but either way, it's good that you have a solution that works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.