<asp:GridView ID ="FileGrid" runat="server" AutoGenerateColumns="False" OnRowCommand="FileGrid_RowCommand">
<Columns>
<asp:BoundField DataField="OriginalFileName" HeaderText="OriginalFileName" SortExpression="OriginalFileName" />
<asp:BoundField DataField="AttachmentGUID" HeaderText="AttachmentGUID" SortExpression="AttachmentGUID" />
<asp:ButtonField Text="Generate PDF" runat="server" HeaderText="Convert To PDF" CommandName="GeneratePDF_Click" />
</Columns>
</asp:GridView>
Code Behind:
代码背后:
protected void FileGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "GeneratePDF_Click")
{
int num = Convert.ToInt16(e.CommandArgument);
string attachmentGuid = FileGrid.Rows[num].Cells[1].Text;
Response.Redirect("DisplayImage.aspx?AttachmentGUID=" + attachmentGuid);
}
}
I see a lot of solutions using OnClientClick
with a asp:Button
, but I'm unable to use a asp:Button
within a column?
我看到很多使用OnClientClick和asp:Button的解决方案,但是我无法在列中使用asp:Button?
1 个解决方案
#1
0
You can use ScriptManager.RegisterStartupScript
to open up a new window:
您可以使用ScriptManager.RegisterStartupScript打开一个新窗口:
var url = "DisplayImage.aspx?AttachmentGUID=" + attachmentGuid;
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + url + "','_blank')", true);
or you can also try:
或者您也可以尝试:
var url = "DisplayImage.aspx?AttachmentGUID=" + attachmentGuid;
string redirect = "<script>window.open('" + url + "');</script>";
Response.Write(redirect);
#1
0
You can use ScriptManager.RegisterStartupScript
to open up a new window:
您可以使用ScriptManager.RegisterStartupScript打开一个新窗口:
var url = "DisplayImage.aspx?AttachmentGUID=" + attachmentGuid;
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + url + "','_blank')", true);
or you can also try:
或者您也可以尝试:
var url = "DisplayImage.aspx?AttachmentGUID=" + attachmentGuid;
string redirect = "<script>window.open('" + url + "');</script>";
Response.Write(redirect);