hi
below are codes:
<asp:DataList ID="DLFilm" runat="server" RepeatDirection="Vertical" CssClass="Dlfilm">
<ItemTemplate>
<div id="rF27">
<label id="buy5M1"><input type="radio" name="iCheck" id="RB720" runat="server" Visible = '<%#Eval("P720").ToString() == "1" ?true : false %>'/></label>
</div>
<div id="rF2">
<label id="buy5M1"><input type="radio" name="iCheck" id="RB1080" runat="server"/></label>
</div>
<div id="rF2">
<label id="buy5M1"><input type="radio" name="iCheck" id="RBT3D" runat="server"/></label>
</div>
<div id="rF2">
<label id="buy5M1"><input type="radio" name="iCheck" id="RBRip" runat="server"/></label>
</div>
<asp:ImageButton ID="ImageButton1" runat="server" CssClass="imgoederF" OnClick="Imgorder_Click" CommandArgument='<%# Eval("id") %>' ImageUrl="~/Image/Main/order1.png"></asp:ImageButton>
</asp:DataList>
as you see in datalist I have <input type="radio"> and image button that when click on image button it will save data in session:
below are codes:
protected void Imgorder_Click(object sender, EventArgs e)
{
ImageButton ibtn = sender as ImageButton;
RadioButton RB720 = ibtn.NamingContainer.FindControl("RB720") as RadioButton;
RadioButton RB1080 = ibtn.NamingContainer.FindControl("RB1080") as RadioButton;
RadioButton RBT3D = ibtn.NamingContainer.FindControl("RBT3D") as RadioButton;
RadioButton RBRip = ibtn.NamingContainer.FindControl("RBRip") as RadioButton;
RadioButton RBDvd = ibtn.NamingContainer.FindControl("RBDvd") as RadioButton;
int id = Convert.ToInt32((sender as ImageButton).CommandArgument);
DataTable dtFiles = GetFilmInfo(id);
string ImageName = dtFiles.Rows[0][22].ToString();
string Code = dtFiles.Rows[0][4].ToString();
string Daste = dtFiles.Rows[0][1].ToString();
string P720 = dtFiles.Rows[0][11].ToString();
string P1080 = dtFiles.Rows[0][13].ToString();
string DVD = dtFiles.Rows[0][17].ToString();
string DvdRip = dtFiles.Rows[0][15].ToString();
string T3D = dtFiles.Rows[0][190].ToString();
string F720 = dtFiles.Rows[0][192].ToString();
string F1080 = dtFiles.Rows[0][193].ToString();
string FRip = dtFiles.Rows[0][195].ToString();
string F3D = dtFiles.Rows[0][194].ToString();
string Price720 = dtFiles.Rows[0][185].ToString();
string Price1080 = dtFiles.Rows[0][186].ToString();
string PriceDvd = dtFiles.Rows[0][189].ToString();
string PriceDvdRip = dtFiles.Rows[0][188].ToString();
string Price3D = dtFiles.Rows[0][187].ToString();
DataTable dt = new DataTable();
if (Session["Order"] != null)
{
dt = Session["Order"] as DataTable;
}
else
{
dt.Columns.AddRange(new DataColumn[] { new DataColumn("Id",typeof(int)),new DataColumn("ImageName",typeof(string)),new DataColumn("Price",typeof(decimal)),
new DataColumn("code",typeof(string)),new DataColumn("Daste",typeof(string)),new DataColumn("Quality",typeof(string)),new DataColumn("format",typeof(string)) });
}
if (RB720.Checked || RB1080.Checked|| RBT3D.Checked || RBRip.Checked || RBDvd.Checked)
{
if (RB720.Checked)
{
dt.Rows.Add(dt.Rows.Count + 1, ImageName, Price720, Code, Daste, P720, F720 );
}
if (RB1080.Checked)
{
dt.Rows.Add(dt.Rows.Count + 1, ImageName, Price1080, Code, Daste, P1080, F1080 );
}
if (RBRip.Checked)
{
dt.Rows.Add(dt.Rows.Count + 1, ImageName, PriceDvdRip, Code, Daste, DvdRip, FRip);
}
if (RBT3D.Checked)
{
dt.Rows.Add(dt.Rows.Count + 1, ImageName, Price3D, Code, Daste, T3D, F3D);
}
if (RBDvd.Checked)
{
dt.Rows.Add(dt.Rows.Count + 1, ImageName, PriceDvd, Code, Daste, DVD, " ");
}
}
Session["Order"] = dt;
}
but when I click on imagebutton below error happen:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:
Line 300: }
Line 301:
Line 302: if (RB720.Checked || RB1080.Checked|| RBT3D.Checked || RBRip.Checked || RBDvd.Checked)
Line 303: {
Line 304:
|
it doesn't recognise <input type="radio">
what should I do?
Best regards
Neda