Chevy Mark Sunderland

Chevy Mark Sunderland

  • NA
  • 188
  • 163.7k

[C# net4] GridView empty

Sep 17 2013 8:12 AM
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)