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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Hemant KumarRank #1,202 · 1.5K reputationPosted Oct 4, 2011, 3:03 AM EDT
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
}
vishal sahani82 reputationPosted Oct 4, 2011, 3:23 AM EDT
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 4, 2011, 4:53 AM EDT
No Data Found.
Add Above to your GridView as
--------------------------------------------------------------
If this helps you, then mark as "Correct Answer"
Thank You
Suthish NairRank #92 · 22.8K reputationPosted Oct 5, 2011, 10:49 AM EDT
vishal sahani82 reputationPosted Oct 8, 2011, 10:21 PM EDT