This is mydesign part. i am showing panels on dropdwon click but its not working.
i have others tab too in tab container.
<ContentTemplate>
<h3 class="headr">Please Select a Category From Following</h3>
<div class="dropdown">
<asp:Image ID="culD" runat="server" Height="200px" Width="200px" class="dropbtn" ImageUrl="~/User/assets/Images/Explore/c_banner.jpg"></asp:Image>
<div class="dropdown-content">
<asp:DropDownList ID="cult" Class="cultr" runat="server" OnSelectedIndexChanged="cult_SelectedIndexChanged" Width="200px" AutoPostBack="True">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem Value="D">Dance</asp:ListItem>
<asp:ListItem Value="S">Singing</asp:ListItem>
<asp:ListItem Value="o">other</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="dropdown">
<asp:Image ID="sport" runat="server" Height="200px" Width="200px" class="dropbtn" ImageUrl="~/User/assets/Images/Explore/s_banner.jpg" />
<div class="dropdown-content">
<asp:DropDownList ID="sportsD" Class="cultr" runat="server" OnSelectedIndexChanged="sportsD_SelectedIndexChanged" Width="200px" AutoPostBack="True">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem Value="CR">Cricket</asp:ListItem>
<asp:ListItem Value="C">Chess</asp:ListItem>
<asp:ListItem Value="CRM">Carrom</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<asp:UpdatePanel runat="server" ID="dc">
<contenttemplate>
<asp:Panel runat="server" ID="dan" class="npan" Width="900px" Height="500px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Dance Registration)</h3>
<div id="snam" runat="server" class="nam">
<asp:Label ID="Label1" runat="server" Text="Name of participant:"></asp:Label>
<asp:TextBox ID="TextBox1" CssClass="txtcls" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="addm" class="addbtn" runat="server" autopostback="true" Text="Add member" OnClick="addm_Click" />
</div>
<div id="Div3" runat="server" class="nams">
<asp:Label ID="Label3" runat="server" autopostback="true" Text="Name of 2nd participant:"></asp:Label>
<asp:TextBox ID="TextBox2" CssClass="txtscls" runat="server"></asp:TextBox>
</div>
<div id="Div29" runat="server" class="nams">
<asp:Label ID="Label27" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox22" CssClass="agtxt" placeholder="1st" runat="server"></asp:TextBox><asp:TextBox ID="TextBox24" CssClass="agstxt" placeholder="2nd" AutoPostBack="true" runat="server"></asp:TextBox>
</div>
<div id="Div2" runat="server" class="cate">
<asp:Label ID="Label2" runat="server" Text="Select Category:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList1" Class="drpd" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="22">select</asp:ListItem>
<asp:ListItem Value="Ss">Solo</asp:ListItem>
<asp:ListItem Value="Dd">Duet</asp:ListItem>
<asp:ListItem Value="Gg">Group</asp:ListItem>
</asp:DropDownList>
</div>
<div id="divv" class="mobn" runat="server">
<asp:Label ID="Label5" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox4" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div6" runat="server" class="eml">
<asp:Label ID="Label6" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox5" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div7" runat="server" class="yer">
<asp:Label ID="Label7" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList2" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div8" runat="server" class="btndiv">
<asp:Button ID="Button1" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
</contenttemplate>
</asp:UpdatePanel>
<asp:Panel ID="singinp" runat="server" class="npan" Width="800px" Height="700px">
<h3 class="panhed">Please Fill This Form TO Participate(Singing Registration)</h3>
<div id="namep" runat="server" class="nam">
<asp:Label ID="name" runat="server" Text="Name of participant:"></asp:Label>
<asp:TextBox ID="txtname" CssClass="txtcls" TextMode="MultiLine" runat="server"></asp:TextBox>
<asp:Button ID="Button6" class="addbtn" runat="server" autopostback="true" Text="Add member" OnClick="Button6_Click" />
</div>
<div id="namesp" runat="server" class="nams" autopostback="true">
<asp:Label ID="scndname" runat="server" autopostback="true" Text="Name of 2nd participant:"></asp:Label>
<asp:TextBox ID="Txtnames" CssClass="txtscls" AutoPostBack="True" runat="server"></asp:TextBox>
</div>
<div id="Div31" runat="server" class="nams">
<asp:Label ID="Label29" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox25" CssClass="agtxt" placeholder="1st" runat="server"></asp:TextBox><asp:TextBox ID="TextBox26" CssClass="agstxt" placeholder="2nd" AutoPostBack="True" runat="server"></asp:TextBox>
</div>
<div id="cat" runat="server" class="cate">
<asp:Label ID="type" runat="server" Text="Select Category:"></asp:Label>
<asp:DropDownList runat="server" ID="dcat" Class="drpd" Style="width: auto;" OnSelectedIndexChanged="dcat_SelectedIndexChanged">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem Value="1">Solo singing</asp:ListItem>
<asp:ListItem Value="2">Duet singing</asp:ListItem>
<asp:ListItem Value="3">Group singing</asp:ListItem>
</asp:DropDownList>
</div>
<div id="clgn" runat="server" class="clgname">
<asp:Label ID="cname" runat="server" Text="Name of College:"></asp:Label>
<asp:TextBox ID="cnamet" CssClass="clgtxt" runat="server"></asp:TextBox>
</div>
<div id="mob" runat="server" class="mobn">
<asp:Label ID="mobi" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="Imob" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Email" runat="server" class="eml">
<asp:Label ID="emal" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="emao" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="ydrp" runat="server" class="yer">
<asp:Label ID="yr" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="yers" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="submit" runat="server" class="btndiv">
<asp:Button ID="btn" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
<asp:Panel ID="other" runat="server" Class="npan" Width="800px" Height="700px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Other Event Registration)</h3>
<div id="Div1" runat="server" class="nam">
<asp:Label ID="Label8" runat="server" Textmode="MultiLine" Text="Name of participant/s:"></asp:Label>
<asp:TextBox ID="TextBox6" CssClass="txtc" runat="server"></asp:TextBox>
</div>
<div id="Div9" runat="server" class="cate">
<asp:Label ID="Label9" runat="server" Text="Select Category:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList3" Class="drpd">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>Solo </asp:ListItem>
<asp:ListItem>Duet </asp:ListItem>
<asp:ListItem>Group</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div10" runat="server" class="nams">
<asp:Label ID="Label10" runat="server" Text="Specify Event Name:"></asp:Label>
<asp:TextBox ID="TextBox7" CssClass="txtcs" runat="server" Placeholder="Ex-Drama/Fashion Show"></asp:TextBox>
</div>
<div id="Div11" runat="server" class="clgname">
<asp:Label ID="Label11" runat="server" Text="Name of College:"></asp:Label>
<asp:TextBox ID="TextBox8" CssClass="clgtxt" runat="server"></asp:TextBox>
</div>
<div id="Div12" runat="server" class="mobn">
<asp:Label ID="Label12" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox9" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div13" runat="server" class="eml">
<asp:Label ID="Label13" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox10" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div14" runat="server" class="yer">
<asp:Label ID="Label14" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList4" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div15" runat="server" class="btndiv">
<asp:Button ID="Button2" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
<asp:Panel ID="chess" runat="server" Class="npan" Width="800px" Height="700px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Chess Registration)</h3>
<div id="Div4" runat="server" class="nam">
<asp:Label ID="Label4" runat="server" Text="Name of participant/s:"></asp:Label>
<asp:TextBox ID="TextBox3" CssClass="txtc" runat="server"></asp:TextBox>
</div>
<div id="Div16" runat="server" class="nams">
<asp:Label ID="Label16" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox11" CssClass="agtxt" runat="server"></asp:TextBox>
</div>
<div id="Div17" runat="server" class="clgname">
<asp:Label ID="Label17" runat="server" Text="Name of College:"></asp:Label>
<asp:TextBox ID="TextBox12" CssClass="clgtxt" runat="server"></asp:TextBox>
</div>
<div id="Div18" runat="server" class="mobn">
<asp:Label ID="Label18" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox13" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div19" runat="server" class="eml">
<asp:Label ID="Label19" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox14" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div20" runat="server" class="yer">
<asp:Label ID="Label20" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList6" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div21" runat="server" class="btndiv">
<asp:Button ID="Button3" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
<asp:UpdatePanel ID="carup" runat="server">
<ContentTemplate>
<asp:Panel ID="carrom" runat="server" Class="npan" Width="800px" Height="700px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Carrom Registration)</h3>
<div id="Div5" runat="server" class="nam">
<asp:Label ID="Label15" runat="server" Text="Name of participant:"></asp:Label>
<asp:TextBox ID="TextBox15" CssClass="txtcls" runat="server"></asp:TextBox>
<asp:Button ID="Button5" class="addbtn" runat="server" Text="Add member" Autopostback="true" OnClick="Button5_Click" />
</div>
<div id="Div28" runat="server" class="nams">
<asp:Label ID="Label26" runat="server" autopostback="true" Text="Name of 2nd participant:"></asp:Label>
<asp:TextBox ID="TextBox20" CssClass="txtscls" runat="server"></asp:TextBox>
</div>
<div id="Div22" runat="server" class="nams">
<asp:Label ID="Label21" runat="server" autopostback="true" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox16" CssClass="agtxt" placeholder="1st" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox21" CssClass="agstxt" placeholder="2nd" AutoPostBack="true" runat="server"></asp:TextBox>
</div>
<div id="Div23" runat="server" class="clgname">
<asp:Label ID="Label22" runat="server" Text="Name of College:"></asp:Label>
<asp:TextBox ID="TextBox17" CssClass="clgtxt" runat="server"></asp:TextBox>
</div>
<div id="Div24" runat="server" class="mobn">
<asp:Label ID="Label23" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox18" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div25" runat="server" class="eml">
<asp:Label ID="Label24" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox19" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div26" runat="server" class="yer">
<asp:Label ID="Label25" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList5" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div27" runat="server" class="btndiv">
<asp:Button ID="Button4" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID="cricket" runat="server" Class="npan" Width="800px" Height="700px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Cricket Registration)</h3>
<div id="Div30" runat="server" class="nam">
<asp:Label ID="Label28" runat="server" Text="Name of participant/s:"></asp:Label>
<asp:TextBox ID="TextBox23" CssClass="txtcr" TextMode="MultiLine" runat="server"></asp:TextBox>
</div>
<div id="Div37" runat="server" class="clgname">
<asp:Label ID="Label34" runat="server" Text="Name of College:"></asp:Label>
<asp:TextBox ID="TextBox28" CssClass="clgtxt" runat="server"></asp:TextBox>
</div>
<div id="Div38" runat="server" class="mobn">
<asp:Label ID="Label35" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox29" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div39" runat="server" class="eml">
<asp:Label ID="Label36" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox30" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div40" runat="server" class="yer">
<asp:Label ID="Label37" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList8" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div41" runat="server" class="btndiv">
<asp:Button ID="Button7" runat="server" Class="Btncss" Text="Submit" />
</div>
</asp:Panel>
</asp:UpdatePanel>
</ContentTemplate>
my codebehind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class User_Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(#"Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=festopedia;Integrated Security=True");
int FID;
protected void Page_Load(object sender, EventArgs e)
{
showclg();
dan.Visible = false;
other.Visible = false;
singinp.Visible = false;
chess.Visible = false;
cricket.Visible = false;
carrom.Visible = false;
}
public void showclg()
{
if (Request.QueryString["FID"].ToString() == null)
{
Response.Redirect("Explore_Event.aspx");
}
else
{
FID = Convert.ToInt32(Request.QueryString["FID"].ToString());
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from FESTDETAILS where FID='" + FID + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
festexprepeater.DataSource = dt;
festexprepeater.DataBind();
con.Close();
}
}
public void Showevent()
{
}
protected void singb_Click1(object sender, EventArgs e)
{
singinp.Visible = true;
dan.Visible = false;
}
protected void cult_SelectedIndexChanged(object sender, EventArgs e)
{
if (cult.SelectedValue =="D")
{
dan.Visible = true;
singinp.Visible = false;
other.Visible = false;
}
else if (cult.SelectedValue == "S")
{
singinp.Visible = true;
dan.Visible = false;
other.Visible = false;
}
else
{
other.Visible = true;
singinp.Visible = false;
dan.Visible = false;
chess.Visible = false;
}
}
protected void sportsD_SelectedIndexChanged(object sender, EventArgs e)
{
if (sportsD.SelectedValue == "C")
{
dan.Visible = false;
singinp.Visible = false;
other.Visible = false;
chess.Visible = true;
}
else if (sportsD.SelectedValue == "CRM")
{
carrom.Visible = true;
dan.Visible = false;
singinp.Visible = false;
other.Visible = false;
chess.Visible = false;
}
else if (sportsD.SelectedValue == "CR")
{
cricket.Visible = true;
carrom.Visible = false;
dan.Visible = false;
singinp.Visible = false;
other.Visible = false;
chess.Visible = false;
}
}
protected void addm_Click(object sender, EventArgs e)
{
Div3.Visible = true;
dan.Visible = true;
TextBox24.Visible = true;
}
protected void Button5_Click(object sender, EventArgs e)
{
carrom.Visible = true;
TextBox21.Visible = true;
Div28.Visible = true;
}
protected void Button6_Click(object sender, EventArgs e)
{
carrom.Visible = true;
TextBox26.Visible = true;
namesp.Visible = true;
singinp.Visible = true;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedValue == "Dd")
{
addm.Visible = true;
}
if (DropDownList1.SelectedValue == "Gg")
{
TextBox1.TextMode = TextBoxMode.MultiLine;
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
int charRows = 0;
string tbCOntent;
int chars = 0;
tbCOntent = TextBox1.Text;
TextBox1.Columns = 10;
chars = tbCOntent.Length;
charRows = chars / TextBox1.Columns;
int remaining = chars - charRows * TextBox1.Columns;
if (remaining == 0)
{
TextBox1.Rows = charRows;
TextBox1.TextMode = TextBoxMode.MultiLine;
}
else
{
TextBox1.Rows = charRows + 1;
TextBox1.TextMode = TextBoxMode.MultiLine;
}
}
protected void dcat_SelectedIndexChanged(object sender, EventArgs e)
{
if (dcat.SelectedValue == "2")
{
Button6.Visible = true;
}
}
}
when i am clicking on image drop down panel is not getting visible.
Related
I have a a couple of radiobuttonlists & checkboxlist that is currently set to AutoPostback=true inside an updatepanel. The async postback of updatepanel is working for checkboxlist but not for radiobuttonlists.
This is my code:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="topBar$odsMainProduct" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<div id="<%# Eval("main_product_id") %>" class="menu"></div>
<br></br>
<br></br>
<br></br>
<div class="divMainProduct">
<h2 style="font-weight: bold; font-stretch: ultra-expanded; margin-bottom: -4px"><%# Eval("name") %></h2>
<div style="margin-bottom: 10px">
<asp:Label ID="lblMainProductDescription" Font-Size="10px" EnableViewState="false" runat="server" Text='<%# Eval("description") %>'></asp:Label>
</div>
</div>
<div class="accordion" id="acc">
<asp:Repeater ID="Repeater2" runat="server" DataSourceID="odsMainProduct0" OnItemDataBound="Repeater2_ItemDataBound">
<ItemTemplate>
<div class="card">
<div class="card-header" id="h<%# Eval("product_id") %>" aria-expanded="false" data-toggle="collapse" data-target="#c<%# Eval("product_id") %>">
<asp:HiddenField ID="hfProductId" runat="server" Value='<%# Eval("product_id") %>' />
<asp:HiddenField ID="hfMainProductId" runat="server" Value='<%# Eval("main_product_id") %>' />
<table style="width: 100%;">
<tr>
<td style="width: 70%">
<asp:Label runat="server" Text='<%# Eval("name") %>' CssClass="linkbutton"></asp:Label>
<br />
<asp:Label runat="server" Text='<%# Eval("description") %>' Font-Size="8px" CssClass="linkbutton"></asp:Label>
</td>
<td style="width: 30%">
<asp:Button ID="btnHeaderSave" runat="server" ForeColor="White" Font-Bold="true" OnClick="btnHeaderSave_Click" BackColor="DarkRed" Font-Size="15px" Width="100px" Height="30px" Text="Button" />
</td>
</tr>
</table>
</div>
<div id="c<%# Eval("product_id") %>" class="collapse" aria-labelledby="h<%# Eval("product_id") %>" data-parent="#acc">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="card-body">
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze grootte" Visible="false" ID="pnlSizes">
<asp:RadioButtonList ID="rdblSize" AutoPostBack="true" CssClass="checklist" OnSelectedIndexChanged="rdblSize_SelectedIndexChanged" runat="server"></asp:RadioButtonList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze bijgerecht" Visible="false" ID="pnlExtraOption">
<asp:RadioButtonList ID="rdblExtraOption" CssClass="checklist" runat="server"></asp:RadioButtonList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze garnering" Visible="false" ID="pnlGarnish">
<asp:CheckBoxList ID="chkGarnish" AutoPostBack="true" CssClass="checklist" OnSelectedIndexChanged="chkGarnish_SelectedIndexChanged" runat="server" RepeatColumns="4"></asp:CheckBoxList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze saus" Visible="false" ID="pnlSauce">
<asp:RadioButtonList ID="rdblSauce" AutoPostBack="true" CssClass="checklist" runat="server"></asp:RadioButtonList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze extra saus" Visible="false" ID="pnlExtraSauce">
<asp:RadioButtonList ID="rdblExtraSauce" AutoPostBack="true" CssClass="checklist" runat="server"></asp:RadioButtonList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze drank" Visible="false" ID="pnlDrink">
<asp:CheckBoxList ID="chklExtraDrink" AutoPostBack="true" CssClass="checklist" runat="server"></asp:CheckBoxList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze extra's" Visible="false" ID="pnlExtras">
<asp:CheckBoxList ID="chkExtras" CssClass="checklist" runat="server"></asp:CheckBoxList>
</asp:Panel>
<div style="margin-top: 10px; margin-bottom: 5px; text-align: center">
<asp:Button ID="btnSave" runat="server" ForeColor="White" Font-Bold="true" OnClick="btnSave_Click" BackColor="DarkRed" Font-Size="15px" Width="80%" Height="30px" Text="Button" />
<%--<input type="button" id="btnSave2" onclick="getid();" style="color: white; font-weight: bold; background-color: DarkRed; font-size: 15px; width: 100px; height: 30px" value="Button" />--%>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<asp:ObjectDataSource ID="odsMainProduct0" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductsByMainProductId" TypeName="ProductBLL">
<SelectParameters>
<asp:Parameter Name="mainProductId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</ItemTemplate>
</asp:Repeater>
Is this a limitation of UpdatePanel or am I doing something wrong here ?
This is the server-side code for radiobuttonlist rdblSize:
protected void rdblSize_SelectedIndexChanged(object sender, EventArgs e)
{
RepeaterItem row = ((RepeaterItem)((RadioButtonList)sender).NamingContainer);
Button btnSave = (Button)row.FindControl("btnSave");
btnSave.Text = "€" + getPrice(row);
}
protected Decimal getPrice(RepeaterItem ai)
{
HiddenField hfProductId = (HiddenField)ai.FindControl("hfProductId");
RadioButtonList rdbl = (RadioButtonList)ai.FindControl("rdblSize");
Decimal price = 0;
foreach (Product product in productList)
{
if (product.productId == Convert.ToInt32(hfProductId.Value))
{
if (rdbl != null && rdbl.SelectedValue != "")
{
if (product.priceId == Convert.ToInt32(rdbl.SelectedValue))
{
price = product.value;
}
}
else
{
if (product.priceId == Global.nvtPriceId)
{
price = product.value;
}
}
}
}
return price;
}
Seems like you have not set "AutoPostBack=true" for the radiobuttonlist. Set this property and try, should work.
Working for me with below code
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="card-body">
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze extra saus" Visible="true" ID="pnlExtraSauce">
<asp:RadioButtonList ID="rd" AutoPostBack="true" CssClass="checklist" runat="server"></asp:RadioButtonList>
</asp:Panel>
<asp:Panel runat="server" CssClass="pnl" GroupingText="Keuze extra's" Visible="true" ID="pnlExtras">
<asp:CheckBoxList ID="chk" CssClass="checklist" AutoPostBack="true" runat="server"></asp:CheckBoxList>
</asp:Panel>
<div style="margin-top: 10px; margin-bottom: 5px; text-align: center">
<asp:Button ID="btnSave" runat="server" ForeColor="White" Font-Bold="true" OnClick="btnSave_Click" BackColor="DarkRed" Font-Size="15px" Width="80%" Height="30px" Text="Button" />
</div>
</div>
</ContentTemplate>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rd.Items.Add(new ListItem("One", "1"));
rd.Items.Add(new ListItem("Two", "2"));
rd.Items.Add(new ListItem("Three", "3"));
chk.Items.Add(new ListItem("One", "1"));
chk.Items.Add(new ListItem("Two", "2"));
chk.Items.Add(new ListItem("Three", "3"));
}
}
I have form inside panel and I am inserting data into the database by using a stored procedure from form. It doesn't throw any error, but it is not showing data in the database. Code works successfully but columns in tables are empty.
This is my stored procedure:
CREATE procedure [dbo].[spDREG]
(#pname varchar(250),
#spname varchar(250),
#age int,
#spage int,
#cat varchar(50),
#mno bigint,
#emlid varchar(250),
#years varchar(50)
)
AS
BEGIN
DECLARE #dregid INT = ##identity
INSERT INTO DREG(P_NAME, SECP_NAME, AGE, AGET, CAT, MOB_NO, EMAILD, YEARS)
VALUES(#pname, #spname, #age, #spage, #cat, #mno, #emlid, #years)
END
This is my code behind
protected void Dsbtn_click(object sender, EventArgs e)
{
string psname ="spDREG"; ;
con.Open();
SqlCommand cmd = new SqlCommand(psname,con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#pname", TextBox1.Text.ToString());
cmd.Parameters.AddWithValue("#spname", TextBox2.Text.ToString());
cmd.Parameters.AddWithValue("#age", TextBox22.Text.ToString());
cmd.Parameters.AddWithValue("#spage", TextBox24.Text.ToString());
cmd.Parameters.AddWithValue("#cat", DropDownList1.Text.ToString());
cmd.Parameters.AddWithValue("#mno", TextBox4.Text.ToString());
cmd.Parameters.AddWithValue("#emlid", TextBox5.Text.ToString());
cmd.Parameters.AddWithValue("#years", DropDownList2.Text.ToString());
cmd.ExecuteNonQuery();
con.Close();
dreglbl.Text = "You have successfully registered";
}
This is my design part
<asp:Panel runat="server" ID="dan" class="npan" Width="900px" Height="500px">
<h3 style="text-align: center" class="panhed">Please Fill This Form TO Participate(Dance Registration)</h3>
<div id="snam" runat="server" class="nam">
<asp:Label ID="Label2" runat="server" Text="Name of participant:"></asp:Label>
<asp:TextBox ID="TextBox1" CssClass="txtcls" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="addm" class="addbtn" runat="server" autopostback="true" Text="Add member" OnClick="addm_Click" />
</div>
<div id="Div3" runat="server" class="nams">
<asp:Label ID="Label3" runat="server" autopostback="true" Text="Name of 2nd participant:"></asp:Label>
<asp:TextBox ID="TextBox2" CssClass="txtscls" runat="server"></asp:TextBox>
</div>
<div id="Div29" runat="server" class="nams">
<asp:Label ID="Label27" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="TextBox22" CssClass="agtxt" placeholder="1st" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox24" CssClass="agstxt" placeholder="2nd" AutoPostBack="true" runat="server"></asp:TextBox>
</div>
<div id="Div2" runat="server" class="cate">
<asp:Label ID="Label4" runat="server" Text="Select Category:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList1" Class="drpd" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="22">select</asp:ListItem>
<asp:ListItem Value="Ss">Solo</asp:ListItem>
<asp:ListItem Value="Dd">Duet</asp:ListItem>
<asp:ListItem Value="Gg">Group</asp:ListItem>
</asp:DropDownList>
</div>
<div id="divv" class="mobn" runat="server">
<asp:Label ID="Label5" runat="server" Text="Mobile No:"></asp:Label>
<asp:TextBox ID="TextBox4" CssClass="mobtxt" runat="server"></asp:TextBox>
</div>
<div id="Div6" runat="server" class="eml">
<asp:Label ID="Label6" runat="server" Text="E-Mail:"></asp:Label>
<asp:TextBox ID="TextBox5" CssClass="emtxt" runat="server"></asp:TextBox>
</div>
<div id="Div7" runat="server" class="yer">
<asp:Label ID="Label7" runat="server" Text="Select Year:"></asp:Label>
<asp:DropDownList runat="server" ID="DropDownList2" Class="drpds">
<asp:ListItem>select</asp:ListItem>
<asp:ListItem>First</asp:ListItem>
<asp:ListItem>Second</asp:ListItem>
<asp:ListItem>Third</asp:ListItem>
<asp:ListItem>other</asp:ListItem>
</asp:DropDownList>
</div>
<div id="Div8" runat="server" class="btndiv">
<asp:Button ID="Dsbtn" runat="server" Class="Btncss" Text="Submit" OnClick="Dsbtn_click" />
<asp:Label ID="dreglbl" runat="server" Text="label"></asp:Label>
</div>
</asp:Panel>
Please solve it guys. Thank you
I have a multiple records in a Grid view inside an update panel, Grid-view has ImageButton , onclick of this button I am displaying a ModalPopupExtender to display details of selected row. Then I close the dialog using close button.
Everything works fine until I open and close the modelpopup 10 times , after that page styles gets disturbed and page start looking ugly. When I remove the update panel then everything works fine but I need update panel for smooth UI experience.
My code is below, please help me as soon as possible , I am stuck because of this. temporarily , I am handling this by dopostback on 10th time so that user doesn't experience refresh everytime.
aspx code.
<asp:UpdatePanel ID="udpDocuments" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="Content">
<h1 class="HomePageHeading">Standard Operating Procedures, Guidelines, and Policies</h1>
<div class="ClearFix MarginBottom30">
<div class="SeriesInformation">
<h2>Series</h2>
<ol class="ValueList">
<li>1.000 - <span>Personnel Procedures</span>
</li>
<li>2.000 - <span>Veterinary Care/Laboratory Animal Medicine</span>
</li>
<li>3.000 - <span>Animal Husbandry/Facility Operations</span>
</li>
<li>4.000 - <span>Safety</span>
</li>
<li>5.000 - <span>Technical Procedures</span>
</li>
<li>6.000 - <span>Administration</span>
</li>
</ol>
</div>
<div class="PolicyNumberAbbr">
<h2>SOP/Policy Number Abbreviations</h2>
<ol class="ValueList">
<li>P = <span>Policy</span>
</li>
<li>G = <span>Guidelines</span>
</li>
<li>B = <span>Bethesda</span>
</li>
<li>F = <span>Frederick</span>
</li>
</ol>
</div>
</div>
<asp:Panel ID="SearchCriteria" runat="server" DefaultButton="btnSearch">
<div class="FilterWrap" style="clear: both;">
<fieldset class="FnlFieldSet">
<legend class="Clip">Filter SOP Listings</legend>
<ol class="InputFields">
<li>
<asp:Label Text="Filter by:" runat="server" ID="lblSortOrder" AssociatedControlID="ddlSortCriteria" />
<ol class="HorizontalInput">
<li>
<asp:DropDownList ID="ddlSortCriteria" runat="server" SelectMethod="Load_Filter"
OnSelectedIndexChanged="ddlSortCriteria_SelectedIndexChanged" AutoPostBack="true"
AppendDataBoundItems="true" DataTextField="Value" DataValueField="Key">
</asp:DropDownList>
<asp:DropDownList ID="ddlCampus" Visible="false" runat="server" SelectMethod="Load_Campus" AppendDataBoundItems="true" DataTextField="value" DataValueField="key">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<asp:DropDownList ID="ddlSeries" Visible="false" runat="server" SelectMethod="Load_Series" AppendDataBoundItems="true" DataTextField="Name" DataValueField="Id">
<asp:ListItem Text="[Select]" Value="0" />
</asp:DropDownList>
<dms:WatermarkTextBox ID="wmTitle" runat="server" MaxLength="60" Columns="30" WatermarkText="Title" />
</li>
<li>
<span class="InputButtonWrapper HasIcon SearchIcon">
<asp:Button ID="btnSearch" Text="Search" OnClick="btnSearch_Click" runat="server" />
</span>
<asp:Button ID="btnReset" Text="Reset" OnClick="btnReset_Click" runat="server" />
</li>
</ol>
</li>
</ol>
</fieldset>
</div>
</asp:Panel>
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<ItemTemplate>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.MainFileAttachment==null?string.Empty:Item.MainFileAttachment.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.Title %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Number" SortExpression="RevisionNumber">
<ItemTemplate>
<asp:Label ID="lblRevisionNumber" runat="server" Text='<%# Item.RevisionNumber %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Revision Date" SortExpression="RevisionDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.RevisionDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Effective Date" SortExpression="EffectiveDate">
<ItemTemplate>
<%# string.Format("{0:d}", Item.EffectiveDate)%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Campus" SortExpression="LocationId">
<ItemTemplate>
<%# Dms.Framework.Extensions.EnumExtensions.Description(Item.LocationId) %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
<div>
<%-- OnCancelScript="__doPostBack('Ok','')" is added to fix the issue when you open the model popup 10 times and on 11th time it mashed up the UI--%>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
OnCancelScript="OnCloseButtonClientClick()"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</div>
</div>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:HiddenField ID="closeCount" ClientIDMode="Static" Value="0" runat="server" />
<script type="text/javascript">
var count = 0;
function OnCloseButtonClientClick() {
if (count == 8) {
//__doPostBack('Ok', '');
count = 0;
}
else {
count = count + 1;
}
return false;
}
</script>
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
mpeAttachments.Show();
}
}
Got solution, It is only about moving code around update panel:
ASPX code:
<dms:GridView ID="gvSOPDetails" runat="server" AllowPaging="true" PageSize="50" AllowSorting="true" DataKeyNames="Id"
AutoGenerateColumns="False" SelectMethod="SopListingGrid_GetItem" Width="100%"
OnRowCommand="gvSOPDetails_RowCommand" OnRowDataBound="gvSOPDetails_RowDataBound"
ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Sop">
<Columns>
<asp:TemplateField HeaderText="SOP/Policy#" SortExpression="Number">
<ItemTemplate>
<asp:Label ID="lblNumber" runat="server" Text='<%# Item.Number %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachments" ItemStyle-HorizontalAlign="center">
<ItemTemplate>
<asp:ImageButton ID="imgBtnViewAttachment" runat="server" CommandName="ViewAttachment"
Enabled="true" CommandArgument='<%# Item.Id %>'
Text="Delete" ImageUrl="~/Media/Images/modal-open-icon.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No records match your search criteria.
</EmptyDataTemplate>
</dms:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID="pnlAttachmentsForSelectedSOP" Style="display: none" runat="server">
<div>
<div class="PopupHeader">
<asp:ImageButton ID="imgBtnPopupClose" CssClass="ModalCloseButton" runat="server" ImageUrl="~/Media/Images/modal-close-icon.png" />
</div>
<div class="PopupBody">
<div class="PopupTitle">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
<span>attachments</span>
</div>
<asp:UpdatePanel ID="upAttachmentList" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSupportingAttachments" runat="server">
<ul>
<asp:ListView runat="server" ID="lvSupportingAttachments" DataKeyNames="Id" ItemType="Dms.Css.Ncif.Lasp.SopTraining.Biz.LaspSopTraining.Attachment"
SelectMethod="LoadModelPopupAttachment">
<ItemTemplate>
<li>
<span>
<asp:HyperLink runat="server" ID="lnkDeleteResponderIssueImage" NavigateUrl="<%# Item.ResourceUrl %>" CssClass="FileDownloadLink" Target="_blank" Text='<%# Item.FileName %>'></asp:HyperLink>
</span>
</li>
</ItemTemplate>
</asp:ListView>
</ul>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Panel>
<asp:Button ID="btnShowModelPopup" runat="server" Text="Button" CssClass="HideModelPopupButton" />
<asp:HiddenField ID="hfSelectedSOP" runat="server" />
<cc1:ModalPopupExtender ID="mpeAttachments" runat="server"
CancelControlID="imgBtnPopupClose"
TargetControlID="btnShowModelPopup" PopupControlID="pnlAttachmentsForSelectedSOP"
PopupDragHandleControlID="PopupHeader" Drag="true"
RepositionMode="RepositionOnWindowResizeAndScroll"
BackgroundCssClass="ModalPopupBG">
</cc1:ModalPopupExtender>
ASPX.cs: code:
protected void gvSOPDetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewAttachment")
{
hfSelectedSOP.Value = (string)e.CommandArgument;
mpeAttachments.TargetControlID = "btnShowModelPopup";
lvSupportingAttachments.DataBind();
upAttachmentList.Update();
mpeAttachments.Show();
}
}
I am using datalist for showing datas. Datas are test questions with 4 options.I have 50 questions displaying in datalist.
By using ItemDataBound event - i am making visible only one question with 4 options to user. Remaining questions are invisible . In the Itemdatabound event - i am assigning id to the radio buttons. but also id is not assigned to the datalist ,it showing different id.
<div class="widget">
<div class="widget-header" align="center" style="background: #4a98c9; color: #FFFFFF;">
<h4>
<asp:Label ID="Label5" runat="server" Text="Question : "></asp:Label>
<asp:Label ID="lblQuestionNo" runat="server" Text="0 of 0"></asp:Label></h4>
<asp:HiddenField ID="HdCurrentQuestSlNo" runat="server" />
<asp:HiddenField ID="HdfMinTime" runat="server" />
<asp:HiddenField ID="HdfSecTime" runat="server" />
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HdfQSlNo" runat="server" />
<asp:HiddenField ID="HdQuestCount" runat="server" Value="0"/>
</div>
<div class="widget-content">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="PanelQuestBlock" runat="server" ScrollBars="Vertical" Width="100%" Height="325px">
<asp:DataList runat="server" ID="DataListQuestion"
onitemdatabound="DataListQuestion_ItemDataBound"
onitemcreated="DataListQuestion_ItemCreated">
<ItemTemplate>
<div class="questdisplayId" id="divQuestBlock" runat="server">
<div>
<asp:HiddenField ID='HdSlNo' runat="server" Value='<%# Eval("SlNo") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdUserQuestId" runat="server" Value='<%# Eval("UserQuestionId") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdTotalOptions" runat="server" Value='<%# Eval("TotalOptions") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdQuestAnsweredTimeSecs" runat="server" Value='<%# Eval("AnsweredTimeSecs") %>' ClientIDMode="Static"/>
<asp:HiddenField ID="HdOptionAnswered" runat="server" Value='<%# Eval("OptionAnswered") %>' ClientIDMode="Static"/>
</div>
<div>
<asp:Label ID="Question" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
</div>
<div class="answer-row" id="divOption1" runat="server">
<asp:RadioButton ID="Option1" runat="server" GroupName="Answer" value="1" Text='<%# Eval("Option1") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt1" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption2" runat="server">
<asp:RadioButton ID="Option2" runat="server" GroupName="Answer" value="2" Text='<%# Eval("Option2") %>'
CssClass="rdbtn" Style="vertical-align: middle" ClientIDMode="Static"/>
<asp:Label ID="lblOpt2" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption3" runat="server">
<asp:RadioButton ID="Option3" runat="server" GroupName="Answer" value="3" Text='<%# Eval("Option3") %>'
CssClass="rdbtn" Style="vertical-align: top; left: auto;" ClientIDMode="Static"/>
<asp:Label ID="lblOpt3" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption4" runat="server">
<asp:RadioButton ID="Option4" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option4") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt4" runat="server" Text=""></asp:Label>
</div>
<div class="answer-row" id="divOption5" runat="server">
<asp:RadioButton ID="Option5" runat="server" GroupName="Answer" value="4" Text='<%# Eval("Option5") %>'
CssClass="rdbtn" Style="vertical-align: text-top" ClientIDMode="Static"/>
<asp:Label ID="lblOpt5" runat="server" Text=""></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="row">
<div class="span8" align="center">
<asp:Button ID="btnClear" runat="server" Text="Clear Selection"
CssClass="btn btn-warning" OnClientClick="Clearbutton();"
/>
<asp:Button ID="btnSave" runat="server" Text="Save & Next" CssClass="btn btn-success" OnClientClick="Savebutton()"/>
</div>
<div class="span4" align="center">
<asp:Button ID="btnReview" runat="server" Text="Mark Review & Next" CssClass="btn btn-info" OnClientClick="Reviewbutton()"/>
<asp:Button ID="btnFinish" runat="server" Text="Finish" CssClass="btn btn-danger" OnClientClick="Finishbutton()"/>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReview" />
<asp:AsyncPostBackTrigger ControlID="btnClear" />
<asp:AsyncPostBackTrigger ControlID="btnSave" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataListQuestion" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HiddenField HdSlNo = (HiddenField)e.Item.FindControl("HdSlNo");
RadioButton Option1 = (RadioButton)e.Item.FindControl("Option1");
RadioButton Option2 = (RadioButton)e.Item.FindControl("Option2");
RadioButton Option3 = (RadioButton)e.Item.FindControl("Option3");
RadioButton Option4 = (RadioButton)e.Item.FindControl("Option4");
RadioButton Option5 = (RadioButton)e.Item.FindControl("Option5");
Option1.ID = "rdbtnoption1_" + HdSlNo.Value.ToString();
Option2.ID = "rdbtnoption2_" + HdSlNo.Value.ToString();
Option3.ID = "rdbtnoption3_" + HdSlNo.Value.ToString();
Option4.ID = "rdbtnoption4_" + HdSlNo.Value.ToString();
Option5.ID = "rdbtnoption5_" + HdSlNo.Value.ToString();
}
In my design page code , using Datalist i am binding 50 questions . while binding itself i am hiding 2 to 50 questions . Question 1 only visible. I tried to give dynamic id for every questions and options using event databound and rowcreated. First it got error , after that i changed properties as ClientIDMode="Static" for controls.it shown different id. But if i click any button event again it clear the id's.again it shows old ids only.
When I want to read e.CommandArgument then I get error saying "Input string was not in a correct format.". My markup portion is like bellow:
<asp:GridView ID="GridViewAllProducts" runat="server"
AutoGenerateColumns="False" GridLines="None"
AllowPaging="True" Width="100%"
EmptyDataText="هیچ محصولی پیدا نشد"
onrowcommand="GridViewAllProducts_RowCommand"
onrowdeleting="GridViewAllProducts_RowDeleting"
OnPageIndexChanging="GridViewAllProducts_PageIndexChanging">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div class='rowTableDiv rowAllNewsUC'>
<asp:HiddenField ID="hiddenId" runat="server" Value='<%# Bind("Id") %>' />
<img id="imgImage" src='<%# Bind("Image") %>' class="imgNewsAllNewsUC noBorder" alt="" runat="server" />
عنوان محصول: <asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label><br />
گروه: <asp:Label ID="lblCategory" runat="server" Text='<%# ProductC.GetProductCategoryName(Convert.ToInt32(Eval("CategoryId"))) %>'></asp:Label><br />
کد: <asp:Label ID="lblCode" runat="server" Text='<%# Bind("Code") %>'></asp:Label><br />
ابعاد: <asp:Label ID="lblDimention" runat="server" Text='<%# Bind("Dimention") %>'></asp:Label><br />
تعداد رنگ: <asp:Label ID="lblNumberOfColors" runat="server" Text='<%# Bind("NumberOfColors") %>'></asp:Label><br />
قیمت: <asp:Label ID="lblPrice" runat="server" Text='<%# nmsPublicClass.PublicClassC.ThousandSeparator(Convert.ToDecimal(Eval("Price"))) %>'></asp:Label>
<asp:LoginView ID="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="Administrator">
<ContentTemplate>
<div class='rowTableDiv rowInfoAllNewsUC'>
<asp:Panel ID="pnlEdit" CssClass='colTableDiv' runat="server">
<div class='colTableDiv colInfoAllNewsUC'>
<asp:LinkButton ID="lbEdit"
CommandArgument='<%# Bind("Id") %>'
PostBackUrl='<%# String.Format("~/Page/Admin/InsertProduct.aspx?Mode=Edit&Id={0}", Eval("Id"))%>'
Font-Underline="false"
CommandName="edit"
runat="server">
<img id='img2' class='noBorder imgEditAllNewsUC' src="../../image/note_edit.png" alt="ویرایش" />
ویراش</asp:LinkButton>
<asp:LinkButton ID="lbDelete" CommandArgument='<%# Bind("Id") %>' Font-Underline="false" CommandName="delete" runat="server">
<img id='img1' class='noBorder imgEditAllNewsUC' src="../../image/delete.png" alt="حذف" />
حذف</asp:LinkButton>
</div>
</asp:Panel>
</div>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<div class="divHidden">
<asp:Label ID="lblID" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataRowStyle CssClass="lblError" />
<PagerStyle CssClass="pagerGridView" />
</asp:GridView>
My code behind is like bellow:
protected void GridViewAllProducts_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "delete")
{
int productId = Convert.ToInt32(e.CommandArgument);
string image = new ProductC().GetProductBy_Id(productId).Image;
Result r = new ProductC().DeleteBy_Id(productId);
if (r.IsSuccess)
{
File.Delete(Server.MapPath(image));
}
GridViewAllProducts.DataSource = new ProductC().GetAllProducts();
GridViewAllProducts.DataBind();
}
}
I get error "Input string was not in a correct format." at the following line:
int productId = Convert.ToInt32(e.CommandArgument);
What is the problem. Please help me. Thank you.