citizenzen
Programmer
Hello.
I am receiving an error when I bind to a dropdownlist.
Object reference not set to an instance of an object. at modifyProgramming.fillLibrary() in c:\Inetpub\ 313
I have a similar page which functions fine, but I don't see where my error lies on this page. How can there be an error with the datasource?
I am receiving an error when I bind to a dropdownlist.
Object reference not set to an instance of an object. at modifyProgramming.fillLibrary() in c:\Inetpub\ 313
I have a similar page which functions fine, but I don't see where my error lies on this page. How can there be an error with the datasource?
Code:
private void fillLibrary()
{
string showu = ConfigurationManager.ConnectionStrings["RevisedTapeLibrary"].ConnectionString;
SqlConnection libconn = new SqlConnection(showu);
SqlCommand libcom = new SqlCommand("select * from view_chooseLibraryTG", libconn);
libconn.Open();
DropDownList newlibr = new DropDownList();
DataTable libdt = new DataTable();
foreach (GridViewRow bu in EditProgramGV.Rows)
{
CheckBox rt = (CheckBox)bu.FindControl("selectRowChk");
if (rt != null && rt.Checked)
{
newlibr = (DropDownList)EditProgramGV.FindControl("libdrop");
SqlDataAdapter ji = new SqlDataAdapter(libcom);
ji.Fill(libdt);
newlibr.DataSource = libdt;
newlibr.DataTextField = "Library";
newlibr.DataValueField = "ID";
newlibr.DataBind();
newlibr.AutoPostBack = true;
}
}
libconn.Close();
}