Y
yasodhai
Hi,
I used a dropdown control bind to a datagrid.
<EditItemTemplate>
<aspropDownList ID="FldType_edit" Runat="server" DataSource='<
%#GetFieldType()%>' DataTextField="Type" />
</EditItemTemplate>
The values for the datagrid are retrieved from the database using the
GetFieldType function
public DataSet GetFieldType()
{
SqlDataAdapter fldad = new SqlDataAdapter("SELECT Type
FROM FieldType Order by FID", myConnection);
DataSet fldds = new DataSet();
fldad.Fill(fldds,"FieldType");
return fldds;
}
Then i try to retrieve the selected the values in the database. i
thought of doing this in the update command event.
public void DataGrid_Fields_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DropDownList dd;
dd = (DropDownList)e.Item.FindControl("FieldType_edit");
string fldval=dd.SelectedItem.Value;
Response.Write("Field Value is "+ fldval+" ");
}
}
While executing this i am getting the following error:
System.NullReferenceException: Object reference not set to an instance
of an object.
While debugging, i found the value of dd is "Unexpected value". The
value is not assigned for dd. Kindly help me to come out from that.
Thanks & Regards,
Yasodhai
I used a dropdown control bind to a datagrid.
<EditItemTemplate>
<aspropDownList ID="FldType_edit" Runat="server" DataSource='<
%#GetFieldType()%>' DataTextField="Type" />
</EditItemTemplate>
The values for the datagrid are retrieved from the database using the
GetFieldType function
public DataSet GetFieldType()
{
SqlDataAdapter fldad = new SqlDataAdapter("SELECT Type
FROM FieldType Order by FID", myConnection);
DataSet fldds = new DataSet();
fldad.Fill(fldds,"FieldType");
return fldds;
}
Then i try to retrieve the selected the values in the database. i
thought of doing this in the update command event.
public void DataGrid_Fields_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DropDownList dd;
dd = (DropDownList)e.Item.FindControl("FieldType_edit");
string fldval=dd.SelectedItem.Value;
Response.Write("Field Value is "+ fldval+" ");
}
}
While executing this i am getting the following error:
System.NullReferenceException: Object reference not set to an instance
of an object.
While debugging, i found the value of dd is "Unexpected value". The
value is not assigned for dd. Kindly help me to come out from that.
Thanks & Regards,
Yasodhai