0
在我的GridView中,我有名为'F Notes','P Notes'和ImageColumn的列。点击ImageButton后,弹出窗口打开,显示'F Notes'和'P Notes'中的数据。现在我的问题是我不想在弹出窗口打开时在后台显示'F Notes'和'P Notes'列。我希望数据仅在弹出窗口中可见。我知道如果我更改Visible = false,那么该列将不会显示,但是当我这样做时,弹出窗口中的文本不可见。GridView列可见性
下面是我为HTML和aspx.cs代码:
<asp:BoundField DataField="FNotes" HeaderText="F Notes" Visible="False" SortExpression="FNotes" />
<asp:BoundField DataField="PNotes" HeaderText="P Notes" Visible="False" SortExpression="PNotes" />
<asp:TemplateField HeaderText="Notes">
<ItemTemplate>
<asp:ImageButton ID="btnShowPopup" runat="server" Visible='<%#true.Equals(Eval("notesVisible"))%>' ImageUrl="~/Images/Imgs.jpg" Height="30px" Width="30px" OnClick="Popup" />
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView1.Columns[2].Visible = true;
GridView1.Columns[3].Visible = true;
}
你可以发布'Popup'方法吗? – mshsayem 2013-05-14 01:38:31
嗨mshsayem,下面是我的弹出窗口保护无效弹出窗口(对象发件人,EventArgs e) { ImageButton btndetails = sender as ImageButton; GridViewRow gvrow =(GridViewRow)btndetails.NamingContainer; lblMrNumber.Text = GridView1.DataKeys [gvrow.RowIndex] .Value.ToString(); lblMrNumber.Text = gvrow.Cells [6] .Text; txtFNotes.Text = gvrow.Cells [2] .Text; txtPNotes.Text = gvrow.Cells [3] .Text; this.GridView1_ModalPopupExtender.Show(); } – Valley 2013-05-14 16:14:36
这可能有所帮助:http://stackoverflow.com/questions/2818203/get-datakey-values-in-gridview-rowcommand – mshsayem 2013-05-15 01:39:52