When trying to add new event from the Events page it throws "Object reference not set to an instance of an object" @ Line 25: lp.LocationID = null; I have read every post in all 60 pages of this forum and can't find solution. App code is as follows:
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
object o = Request.QueryString["Action"];
if (o != null)
{
string action = System.Convert.ToString(o).ToLower();
if (action == "new")
{
FormView1.ChangeMode(FormViewMode.Insert);
LocationsPicker lp = (LocationsPicker)(FormView1.FindControl("LocationPicker1"));
lp.LocationID = null;
DurationPicker dp = (DurationPicker)(FormView1.FindControl("dtpicker"));
dp.startDateTime = DateTime.Now;
dp.endDateTime = DateTime.Now.AddHours(5);
TextBox slp = (TextBox)(FormView1.FindControl("staticURLTextBox"));
slp.Enabled = false;
}
else if (action == "delete")
{
SqlDataSource1.Delete();
Response.Redirect("events_list.aspx");
}
else
{
CheckBox cb = (CheckBox)(FormView1.FindControl("CheckBox1"));
TextBox surl = (TextBox)(FormView1.FindControl("staticURLTextBox"));
if (surl.Text != null && surl.Text != "")
{
cb.Checked = true;
surl.Enabled = true;
}
else
{
surl.Enabled = false;
}
}
}
}
}
Is it a fact, or have I dreamt it, that by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? 1851 Nathaniel Hawthorne The House of Seven Gables.
pcnomad
0 Points
1 Post
Add new event throwing error.
Nov 28, 2008 06:17 PM|LINK
protected void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
object o = Request.QueryString["Action"];
if (o != null)
{
string action = System.Convert.ToString(o).ToLower();
if (action == "new")
{
FormView1.ChangeMode(FormViewMode.Insert);
LocationsPicker lp = (LocationsPicker)(FormView1.FindControl("LocationPicker1"));
lp.LocationID = null;
DurationPicker dp = (DurationPicker)(FormView1.FindControl("dtpicker"));
dp.startDateTime = DateTime.Now;
dp.endDateTime = DateTime.Now.AddHours(5);
TextBox slp = (TextBox)(FormView1.FindControl("staticURLTextBox"));
slp.Enabled = false;
}
else if (action == "delete")
{
SqlDataSource1.Delete();
Response.Redirect("events_list.aspx");
}
else
{
CheckBox cb = (CheckBox)(FormView1.FindControl("CheckBox1"));
TextBox surl = (TextBox)(FormView1.FindControl("staticURLTextBox"));
if (surl.Text != null && surl.Text != "")
{
cb.Checked = true;
surl.Enabled = true;
}
else
{
surl.Enabled = false;
}
}
}
}
}