[英]Passing a selected value in the grid view to a pop up panel in the same page
[英]hide panel based on grid view row selection in same page on server side
我在GridView下面有單選按鈕作為列。 我想基於GridView行選擇隱藏或顯示面板,該選擇將在同一頁面的GridView外部呈現。
下面是我的GridView:
<table style="width: 95%; margin-top: 10px;" class="transferCertsTbl">
<tr style="width: 95%">
<td colspan="2">
<asp:GridView ID="gvClearpassCertInfo" runat="server" AutoGenerateColumns="False" GridLines="None"
CellSpacing="1" CellPadding="1"
Width="95%" BorderWidth="0"
AllowSorting="True"
PageSize="30"
OnRowDataBound="gvClearpassCertInfo_RowDataBound"
CssClass="data responsive">
<Columns>
<asp:TemplateField HeaderText="Select" SortExpression="">
<ItemTemplate>
<asp:RadioButton ID="radioChkCert" runat="server" onclick="RadioCheck(this);" /><input type="hidden" id="hdnCertId" runat="server" value='<%# DataBinder.Eval(Container.DataItem, "CertId") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CertificateID" HeaderText="Certificate ID" HeaderStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="partID" HeaderText="Part Number" HeaderStyle-HorizontalAlign="Center"/>
<asp:BoundField DataField="BaseLicense" HeaderText="Base License" Visible="false" />
</Columns>
<EmptyDataRowStyle CssClass="AlternatingRowStyle" />
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
<RowStyle HorizontalAlign="Center" />
<AlternatingRowStyle HorizontalAlign="Center" />
<PagerSettings Visible="False" />
</asp:GridView>
</td>
</tr>
</table>
但是我不確定如何僅基於服務器端的GridView中的行選擇顯示或隱藏。
有人能幫上我對此非常感激的事情嗎?
您可以執行以下操作:
對於單選按鈕標記,添加autopostback = true和OnCheckedChanged =“ radioChkCert_CheckedChanged”,如下所示:
<asp:RadioButton ID="radioChkCert" runat="server" onclick="RadioCheck(this);" autopostback="true" OnCheckedChanged="radioChkCert_CheckedChanged"/>
在后面的代碼中添加函數:
protected void radioChkCert_CheckedChanged(object sender, EventArgs e) { radiobutton radiobtn = (radiobutton)sender; string txt = (((Label)radiobtn.Parent.FindControl("l1")).Text); //l1 is the id of a label in the gridview if ((txt == "CertainCode")) { Certainpanel.Visible = true; } }
我使用標簽的文本來控制顯示哪個面板,在您的情況下,根據哪個控件及其值來選擇它。 我從vb.net轉換為C#,告訴我是否有錯誤
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.