I want dropdownlist to show database value entered by user at the time of filling the form on edit button click but I checked by debugging it my control is ignoring dopdownlist line thats why it is not filling with database value
I had written like this but control is skipping these line and giving error: Object reference not set to an instance of an object. at Jobopedia.SP_edit_new.btnEdit_Click(Object sender, EventArgs e)
DropDownList1.SelectedValue = (grow.FindControl("lblBname") as DropDownList).SelectedValue;
DropDownList2.SelectedValue = (grow.FindControl("lblcity") as DropDownList).SelectedValue;
protected void btnEdit_Click(object sender, EventArgs e)
{
try
{
Button btn = sender as Button;
GridViewRow grow = btn.NamingContainer as GridViewRow;
Id.Value = (grow.FindControl("Id") as Label).Text;
Image img = (grow.FindControl("img") as Image);
txt_email.Text = (grow.FindControl("lblemail") as Label).Text;
txt_link.Text = (grow.FindControl("lblweb") as Label).Text;
txt_img.Text = (grow.FindControl("lblimg") as Label).Text;
txt_name.Text = (grow.FindControl("lblname") as Label).Text;
txt_pay.Text = (grow.FindControl("lblpay") as Label).Text;
txt_toll.Text = (grow.FindControl("lbltoll") as Label).Text;
txt_Address.Text = (grow.FindControl("lblAddress") as Label).Text;
Image1.ImageUrl = img.ImageUrl;
btnUpdate.Visible = true;
DropDownList1.SelectedValue = (grow.FindControl("lblBname") as DropDownList).SelectedValue;
DropDownList2.SelectedValue = (grow.FindControl("lblcity") as DropDownList).SelectedValue;
ddlTimeFrom.SelectedValue = (grow.FindControl("lblopen") as DropDownList).Text;
ddlTimeTo.SelectedValue = (grow.FindControl("lblopen") as DropDownList).Text;
}
catch
{
}
}