Hi all, I have a gridview in my project.
There is a cell that contains a dropdownlist, textbox and button.
My task is when the use clicks "others" in the dropdownlist, the textbox and button should show so that they can add new value into the dropdownlist.
But I got an exception.
"Object reference not set to an instance of an object. " at tbxName.Visible = true
How can I show that?
Please help.
protected void ddlName_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dropDown = sender as DropDownList;
int selectedIndex = dropDown.SelectedIndex;
GridViewRow gvr = dropDown.NamingContainer as GridViewRow;
// GridViewRow gvr = (GridViewRow)gv_retrieve.Rows[index];
DropDownList ddl = gvr.FindControl("ddlName") as DropDownList;
if (ddl.SelectedValue == "others")
{
TextBox tbxName = (TextBox)gv_retrieve.FindControl("tbxName") as TextBox;
tbxName.Visible = true;
}
}