2013-05-13 2 views
0

GridView에 'F Notes', 'P Notes'및 ImageColumn이라는 열이 있습니다. ImageButton을 클릭하면 'F Notes'와 'P Notes'의 데이터를 보여주는 팝업 창이 열립니다. 이제 내 문제는 팝업이 열리면 배경에 'F Notes'및 'P Notes'열이 표시되는 것을 원하지 않는다는 것입니다. 데이터가 팝업에서만 표시되기를 원합니다. Visible = false로 변경하면 열이 표시되지 않지만 팝업 할 때 텍스트가 표시되지 않습니다. 다음은 GridView Column Visibility

는 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; 
    } 
+0

'팝업'방법을 게시 할 수 있습니까? – mshsayem

+0

안녕하세요 mshsayem, 아래 내 팝업 메쉬 보호 된 무효 팝업 (개체 발신자, EventArgs 전자) { ImageButton btndetails = 보낸 사람으로 ImageButton; GridViewRow gvrow = (GridViewRow) btndetails.NamingContainer; lblMrNumber.Text = GridView1.DataKeys [gvrow.RowIndex] .Value.ToString(); lblMrNumber.Text = gvrow.Cells [6]. 텍스트; txtFNotes.Text = gvrow.Cells [2]. 텍스트; txtPNotes.Text = gvrow.Cells [3]. 텍스트; this.GridView1_ModalPopupExtender.Show(); } – Valley

+0

도움이 될 수 있습니다. http://stackoverflow.com/questions/2818203/get-datakey-values-in-gridview-rowcommand – mshsayem

답변

0

"mshsayem는"제안으로 ("Get DataKey values in GridView RowCommand"), 당신이 당신의 "FNotes"를 정의하여 가시성 문제를 우회 할 수 있다고 믿고 "PNotes"를 GridView의 DataKeys로 사용하십시오. 너무 당신의 GridView에서 변경 DataKeyNames : 당신의 "팝업"에서 다음

DataKeyNames="MrNumber,FNotes,PNotes" 

오히려 세포 자체에서 데이터를 가져 오는 것보다 이전에 정의 된 DataKeys를 참조합니다.

protected void Popup(object sender, EventArgs e) { 
    ImageButton btndetails = sender as ImageButton; 
    GridViewRow gvrow = (GridViewRow)btndetails.NamingContainer; 
    lblMrNumber.Text = (string)GridView1.DataKeys[gvrow.RowIndex]["MrNumber"]; 
    lblMrNumber.Text = gvrow.Cells[6].Text; 
    txtFNotes.Text = (string)GridView1.DataKeys[gvrow.RowIndex]["FNotes"]; 
    txtPNotes.Text = (string)GridView1.DataKeys[gvrow.RowIndex]["PNotes"]; 
    this.GridView1_ModalPopupExtender.Show(); 
}