pr_wainwright
asked on
FormView ModeChanged Event (ASP.NET C#)
Hi,
I have the following code where I wish to access a DropDownList box on FormView1's Edit Template after the Edit button is clicked on the FormView's Item template, but I get a NullReferenceException when the FormView's mode changes to Edit. Any help appreciated. Thanks Paul.
protected void FormView1_ModeChanged(obje ct sender, EventArgs e)
{
if (FormView1.CurrentMode == FormViewMode.ReadOnly)
{
laMessageTimes.Text = "Read Only Mode";
}
if (FormView1.CurrentMode == FormViewMode.Edit) //Edit Command button clicked
{
//ddlClientsE is in FormView1's Edit Template
DropDownList ClientDDL = (DropDownList)FormView1.Fi ndControl( "ddlClient sE");
//NullReferenceException Here!
ClientDDL.Items.Add("BG");
laMessageTimes.Text = "Edit Mode";
}
}
I have the following code where I wish to access a DropDownList box on FormView1's Edit Template after the Edit button is clicked on the FormView's Item template, but I get a NullReferenceException when the FormView's mode changes to Edit. Any help appreciated. Thanks Paul.
protected void FormView1_ModeChanged(obje
{
if (FormView1.CurrentMode == FormViewMode.ReadOnly)
{
laMessageTimes.Text = "Read Only Mode";
}
if (FormView1.CurrentMode == FormViewMode.Edit) //Edit Command button clicked
{
//ddlClientsE is in FormView1's Edit Template
DropDownList ClientDDL = (DropDownList)FormView1.Fi
//NullReferenceException Here!
ClientDDL.Items.Add("BG");
laMessageTimes.Text = "Edit Mode";
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have used moved the code into the SQLDataSources DataBinding handler & it now works fine. I will accept your solution as you were my only reply.
Thanks for the help.
Paul.