1
我有以下的Fileds問題與模態彈出和下載的GridView
附件(鏈接按鈕)和評論(鏈接按鈕)
當我在附件點擊我想網格視圖下載文件,當我點擊評論我想在彈出窗口中顯示評論。爲此,我使用了模態彈出窗口。
但按代碼我寫了這個既適用於在頁面加載後在兩個或不工作怎麼解決這個第一次嘗試..
我的網格設計如下
<asp:GridView ID="grdAttaches_Client" runat="server" AutoGenerateColumns="false"
CssClass="GridViewStyle" Width="585px" OnRowCommand="grdAttaches_Client_RowCommand"
OnRowDataBound="grdAttaches_Client_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Attachment Name">
<ItemTemplate>
<asp:LinkButton ID="lblAttachmentName" Text='<%#Eval("AttachmentName")%>' runat="server" CommandName='Attachement' CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' />
<asp:Label ID="lblAttachmentid" runat="server" Visible="false" Text='<%#Eval("Attachmentid")%>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="grid-left-txt2" />
</asp:TemplateField>
<asp:TemplateField HeaderText=" Comment">
<ItemTemplate>
<asp:LinkButton ID="LinkButtonEdit" CommandName="ShowPopup" OnClick="lnkcommentsClick" runat="server"
Text='<%# Eval("Comments").ToString().Substring(0, Math.Min(Eval("Comments").ToString().Length, 10)) %>' CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' > </asp:LinkButton>
<asp:Label ID="lblComments1" runat="server" Visible="false" Text='<%#Eval("Comments")%>'></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="grid-left-txt2" />
</asp:TemplateField>
</Columns>
<RowStyle CssClass="RowStyle" />
<EmptyDataRowStyle CssClass="EmptyRowStyle" />
<PagerStyle CssClass="PagerStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
<SelectedRowStyle CssClass="grid_data" />
<PagerSettings Position="TopAndBottom" />
</asp:GridView>
在命令行我寫如下
if (e.CommandName == "Click")
{
GridViewRow gvRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
LinkButton lbl_bs_id = (LinkButton)gvRow.FindControl("lnkcomments");
//Response.Write(lbl_bs_id.Text);
lnkcommentsClick(lbl_bs_id, EventArgs.Empty);
}
else
{
string fname = e.CommandName.ToString();
int aid = Convert.ToInt32(e.CommandArgument.ToString());
FileDownload(fname, true, aid);
}
我的評論點擊代碼
protected void lnkcommentsClick(object sender, EventArgs e)
{
LinkButton lnkdetails = sender as LinkButton;
// lnkdetails=(LinkButton)e.fi
GridViewRow gvrow = (GridViewRow)lnkdetails.NamingContainer;
if (lnkdetails.Text != string.Empty)
{
lblPopUp.Text = lnkdetails.Text;
mpeModalPopUp.Show();
}
}
但我無法解決多次。當頁面加載時,我可以顯示彈出窗口或文件下載。該怎麼做,以便始終工作