2
Answers

[C# net4] GridView empty

Chevy Mark Sunderland

Chevy Mark Sunderland

11y
1.1k
1
Hello, hope in your help.

My problem is when the GridView is empty in the aspx page I've this error:

Object reference not set to an instance of an object on:


protected void OnDataBound(object sender, EventArgs e)
{
sql = "SELECT ";
sql = sql + " denom
sql = sql + "FROM ";
sql = sql + " tbl_xxx; ";

DropDownList Newcombo = DecoderView.FooterRow.FindControl("Newcombo") as DropDownList;
Newcombo.DataSource = GetData(sql);
Newcombo.DataTextField = "denom";
Newcombo.DataValueField = "denom";
Newcombo.DataBind();
Newcombo.Items.Insert(0, new ListItem("------", ""));
}


in this line:

DropDownList Newcombo = DecoderView.FooterRow.FindControl("Newcombo") as DropDownList;


If I've gridview records to show the aspx page is working ...

Can you help me?
Thank you in advance

Attachment: cs.zip

Answers (2)