C# helpage...

Don
Joined
5 Oct 2005
Posts
11,156
Location
Liverpool
I have this...
foreach (GridViewRow dgi in BookingList.Rows)
{

CheckBox Update = (CheckBox)BookingList.FindControl("CheckBoxUpdate");


DropDownList ModelNumber = (DropDownList)BookingList.FindControl("ddlList");
TextBox PriKey = (TextBox)BookingList.FindControl("PriKey");

string ModelNo = ModelNumber.SelectedItem.Value;
string PrimKey = PriKey.Text;

int Key = Convert.ToInt32(PrimKey);

if (Update.Checked)
{
SQLQueries.UpdateApp(ModelNo, Key);
}
}

but I'm getting this....

Object reference not set to an instance of an object. on the following line...string ModelNo = ModelNumber..SelectedItem.Value
Thanks,

Stelly
 
Associate
Joined
1 Feb 2006
Posts
1,868
Location
Reading
that would suggest that the following line didn't find the control.

DropDownList ModelNumber = (DropDownList)BookingList.FindControl("ddlList");

Check the spelling of the search parameter. It is always advisable to have error checking in place to prevent errors such as this.
 
Back
Top Bottom