I have a gridview Binded on PageLoad(). There is a column with DropDownList. On DropDownList SelectedIndexChange i would need to updated HeaderText of 2 columns.
As shown above on First time SelectedIndexChange, it's not updating HeaderText of either columns.
On second time SelectedIndexChange it's updating columns but with previous selected value.
Not updating with currently selected value.
Below is the code:
protected void dropdowninsareatype_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList dropDownList = sender as DropDownList;
string dtext = Server.HtmlEncode(dropDownList.SelectedItem.Text.ToString());
gridViewfacility.Columns[1].HeaderText = Server.HtmlEncode("No Of / " + dtext);
gridViewfacility.Columns[2].HeaderText = Server.HtmlEncode("Area in Sq Ft. / " + dtext);
}
Page_Load():
protected void Page_Load(object sender, EventArgs e)
{
if (Request.UrlReferrer == null)
{
Response.Redirect("../login.aspx", true);
return;
}
if (Session["udisecode"] == null)
{
Response.Redirect("../login.aspx", true);
return;
}
if (Session["ip"] == null)
{
Response.Redirect("../login.aspx", true);
return;
}
if (!IsPostBack)
{
PageValidate.Validate(Page);
checkCSRFGaurd();
PageValidate.AuthSession(Page);
// lblUdiceCode.Text = Server.HtmlEncode(Session["udisecode"].ToString());
((webMaster)Master).LBLPageName.Text = "Area Details";
PageValidate.CheckSession("udisecode");
try
{
loadareadetails();
}
catch (Exception ex)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('There Is Something Wrong Please Try Again.!!!' )", true);
}
finally
{
}
//areahall.areaHall();
//AssingFields();
}
}