updatepanel for radiobuttonlist - asp.net

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"));
}
}

Related

ASP.NET Label Inside UpdatePanel Not Updating on Selected Index Changed

I am new to ASP.NET and I'm trying to get a Label to update with some information that is grabbed when I hit On selected index changed. The On selected index changed function is called and returns just fine (I've debugged and stepped through the whole thing). The only thing that doesn't work is where I set the text of the Labels I'm trying to update.
This is the function that gets called on the On selected index changed click:
protected void OnClosetIndexChanged(object sender, EventArgs e)
{
{
UpdatePanel updatePanel1 = Row.FindControl("UpdatePanel1") as UpdatePanel;
Label oldSourceQuantity = (Label)Row.FindControl("lblQuantity");
oldSourceQuantity.Text = "0";//Trying to force a value
updatePanel1.Update();
}
}
I know it goes into the if and tries to set the text but nothing happens on the client side.
This is the UpdatePanel I have:
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%" style="background:#F5F5F5" >
<div id="div<%# Eval("componente_id") %>" style="overflow:auto; display:none; position: relative; left: 15px; overflow: auto">
<div class="ExpandTableHeader">
Cambiar la cantidad
</div>
<div class="body">
<label for="validationOfTypeID">Armario:</label>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:DropDownList ID="drCloset" AppendDataBoundItems="True" runat="server" Width="20%" Height="30px" AutoPostBack="true" OnSelectedIndexChanged = "OnClosetIndexChanged"></asp:DropDownList>
<br/>
<label for="validationOfTypeID" visible="false" >cajon</label> <br/>
<asp:DropDownList ID = "drDrawer" AutoPostBack="true" runat="server" Width="20%" Height="30px" >
</asp:DropDownList>
<asp:Label ID="lblQuantity" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostbackTrigger ControlID="drCloset" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<label for="validationOfTypeID"></label>
<asp:DropDownList Height="30px" ID="drOperation" runat="server" >
<asp:ListItem>+</asp:ListItem>
<asp:ListItem>-</asp:ListItem>
</asp:DropDownList>
<asp:TextBox width="50px" ID="txtChangeQuantity" runat="server" TextMode="Number" min="0" step="1" Value="0" ></asp:TextBox>
<asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>
<br/>
</br>
<asp:Button class="btn btn-primary" ID="btnConfirmPurchases" runat="server" Text="Validar" AutoPostback="true" width="20%" />
</div>
<asp:DetailsView id="DetailsView1" DataKeyNames="componente_id" Runat="server" Width="300px" Font-Names="Calibri"/>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>

panel is not working on dropdown click

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.

ASP Modal Popup appears behind gridview after 3 clicks

I have a page with multiple modal popups and a gridview. If i open the popups 3 times the grid goes infront of the popup. I am pretty sure it has somethign to do witht eh update panels but i am stumped.
Here is the Code
<asp:UpdatePanel ID="NewCustCarUP" runat="server">
<ContentTemplate>
<asp:button ID="NewCustButton" runat="server" CssClass="btn btn btn-success" text="Add Customer" OnClick="NewCustButton_Click"/>
<asp:button ID="NewCarButton" runat="server" CssClass="btn btn btn-primary" text="Add Carrier" OnClick="NewCarButton_Click"/>
<!-- MP ADD CUST -->
<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mpAddCust" runat="server" PopupControlID="NewCustPanel" TargetControlID="lnkFake"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowResizeAndScroll">
</cc1:ModalPopupExtender>
<asp:Panel ID="NewCustPanel" runat="server" CssClass="modalPopup" style = "display: none; width:65%; height:90%; overflow:scroll; ">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4"><br />
<asp:Button ID="newCustInsert" runat="server" UseSubmitBehavior="false" OnClick="newCustInsert_Click" CssClass="btn btn-success" ValidationGroup="NewCust" Text="Add Customer" />
<asp:Button ID="btnClose" runat="server" Text="Close" CssClass="btn btn-danger" />
</div>
<div class="col-sm-4 col-md-4 col-lg-4"></div>
</div>
</asp:Panel>
<!-- END MP ADD CUST -->
<!-- MP ADD CARRIER -->
<asp:LinkButton ID="lnkFake1" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="mpAddCar" runat="server" PopupControlID="NewCarPanel" TargetControlID="lnkFake1"
CancelControlID="btnCloseCar" BackgroundCssClass="modalBackground" RepositionMode="RepositionOnWindowResizeAndScroll">
</cc1:ModalPopupExtender>
<asp:Panel ID="NewCarPanel" runat="server" CssClass="modalPopup" style = "display: none; width:65%; height:90%; overflow:scroll; ">
<div class="row">
<div class="col-sm-4">
.....Code with textboxes</div>
<div class="col-sm-4">
<asp:Button ID="InsertCarBtn" runat="server" Text="Add Carrier" CssClass="btn btn-success" OnClick="InsertCarBtn_Click" ValidationGroup="NewCar" />
<asp:Button ID="btnCloseCar" runat="server" Text="Close" CssClass="btn btn-danger" />
</div>
<div class="col-sm-4 col-md-4 col-lg-4"></div>
</div>
</asp:Panel>
<!-- END MP ADD CARRIER -->
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="MPStatusUP" runat="server">
<ContentTemplate>
<asp:panel ID="StatusPanel" runat="server" CssClass="modalPopup" style="z-index: 10000; position: relative;" >
<div class="row">
<div class="col-sm-4">
....Content
</div>
<div class="col-sm-4">
<asp:button ID="StatusbtnUpdate" runat="server" Text="Update" CssClass="btn btn-success" OnClick="StatusbtnUpdate_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="btn btn-danger" OnClientClick = "return Hidepopup()"/>
</div>
<div class="col-sm-4 col-md-4 col-lg-4"></div>
</div>
</asp:panel>
<asp:LinkButton ID="lnkFake3" runat="server"></asp:LinkButton>
<cc1:ModalPopupExtender ID="StatusMP" runat="server" DropShadow="false"
PopupControlID="StatusPanel" TargetControlID = "lnkFake3"
BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="Gridview1UP" runat="server" ChildrenAsTriggers="true"
UpdateMode="Conditional">
<ContentTemplate>
<asp:gridview ID="GridView1" runat="server"
DataSourceID="ActiveLoadsSQL" AutoGenerateColumns="False" BorderStyle="None" BorderWidth="0px" Width="100%"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowDataBound="GridView1_RowDataBound"
DataKeyNames="LoadID" AllowSorting="true" AllowPaging="true" Font-Size="Smaller" CssClass="table table-hover"
pagesize="25">
<Columns>
<asp:TemplateField HeaderText="loadID" InsertVisible="False" SortExpression="loadID">
<ItemTemplate>
<asp:Label ID="loadIDLabel" runat="server" Text='<%# Bind("loadID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</asp:TemplateField>
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Button ID="UpdateStatusModalbtn" OnClick="UpdateStatusModalbtn_Click" runat="server" CommandName="select" CssClass="btn btn-info btn-xs" text="Update"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle VerticalAlign="Top" />
</asp:gridview>
</ContentTemplate>
</asp:UpdatePanel>
It all works great until i get i click on a button 3 times on the status modal inside the GV and 4 times on the Add Customer and carrier outside of the GV. Thanks for your help!!
Fixed with this post
AJAX ModalPopup Pops Behind (Under) Page Content (Negative z-index)
.ModalPopup
{
z-index: 6001 !important;
}
.ModalPopupBackground
{
z-index: 6000 !important;
}

page style get disturbed on ModalPopupExtender on click of button in a gridview in Update panel

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();
}
}

how to dynamically assign id to controls - controls are inside datalist in asp .net

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.

Resources