Yes, GridView is bound and works fine without the Cookies condition. I am using Edit DefaultMode. Below is my full code which returns the error:
Object reference not set to an instance of an object (Line 21). Please assist.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
foreach (DetailsViewRow gvr in DetailsView1.Rows)
{
if ((gvr.RowType == DataControlRowType.DataRow))
{
RadioButtonList rbl = ((RadioButtonList)(gvr.FindControl("radioButtonListI")));
for (int j = 0; (j <= rbl.Items.Count); j++)
{
if ((rbl.Items[j].Value == "5"))
{
if (Request.Cookies["Q1"] != null)
{
Response.Cookies["Q1"].Value = Label2.Text.ToString();
Response.Redirect("../QuestLocal/Q2.aspx");
}
else
{
Response.Cookies["Q1"].Value = Label2.Text.ToString();
Response.Redirect("../QuestLocal/Q3.aspx");
}
}
}
}
}
}
asante_za
Member
16 Points
113 Posts
Re: Condition in Cookie
Apr 26, 2012 12:12 PM|LINK
Yes, GridView is bound and works fine without the Cookies condition. I am using Edit DefaultMode. Below is my full code which returns the error: Object reference not set to an instance of an object (Line 21). Please assist.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button3_Click(object sender, EventArgs e) { foreach (DetailsViewRow gvr in DetailsView1.Rows) { if ((gvr.RowType == DataControlRowType.DataRow)) { RadioButtonList rbl = ((RadioButtonList)(gvr.FindControl("radioButtonListI"))); for (int j = 0; (j <= rbl.Items.Count); j++) { if ((rbl.Items[j].Value == "5")) { if (Request.Cookies["Q1"] != null) { Response.Cookies["Q1"].Value = Label2.Text.ToString(); Response.Redirect("../QuestLocal/Q2.aspx"); } else { Response.Cookies["Q1"].Value = Label2.Text.ToString(); Response.Redirect("../QuestLocal/Q3.aspx"); } } } } } }