Hi Guys I have a Gridview which has some empty cells I want to change the text of those cells to something else like "no data found" or anything.
How do i do it
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
vishal sahaniPosted Oct 9, 2011, 2:21 AM
Suthish NairPosted Oct 5, 2011, 2:49 PM
Prabhu RajaPosted Oct 4, 2011, 8:53 AM
No Data Found.
Add Above to your GridView as
--------------------------------------------------------------
If this helps you, then mark as "Correct Answer"
Thank You
vishal sahaniPosted Oct 4, 2011, 7:23 AM
Hemant KumarPosted Oct 4, 2011, 7:03 AM
First you need to wrap your code in a
LabelorLiteralcontrol so that you can reference it properly. What's happening is that there's no way for the system to keep track of it, because there's no control associated with the text. It's the control's responsibility to add its contents to viewstate.You need to use gridView.FindControl("controlName"); to get the control in the row. From there you can get at its properties including
Text.You can also get at the DataItem property of the Row in question and cast it to the appropriate type and extract the information directly.
if(lblCellText.Text==String.Empty)
{
//Do Something
}else
{
//Do Something
}