在下面的代码中我在网格视图中有一个网格视图我有一个链接按钮当我点击链接按钮它应该打开一个弹出窗口.pls帮我做到这一点。
<asp:GridView ID="gvActList" runat="server" Font-Size="Smaller" Width="100%" CssClass="tableStyle"
EmptyDataText="No Data Found" AllowPaging="false"
CellPadding="4" AutoGenerateColumns="False" OnRowDataBound="gvActList_RowDataBound">
<FooterStyle Font-Bold="True" CssClass="tablefooter" />
<RowStyle CssClass="tableRow1" />
<SelectedRowStyle Font-Bold="True" CssClass="tableRowHighlight" />
<HeaderStyle Font-Bold="True" CssClass="tableHeader" Font-Size="9px" />
<Columns>
<asp:TemplateField HeaderText="TM Activity Code" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%" HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Activity_Code" runat="server" Visible="true" Text='<%# Bind("ACTIVITY_CODE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="19%" HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_ACTDESC" runat="server" Text='<%# Bind("ACTIVITY_DESC") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="User Details" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_User_Details" runat="server" Text='<%# Bind("CREATED_BY") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Type" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_PROMO_TYPE" runat="server" Text='<%# Bind("PROMO_TYPE") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblCatgDescription" runat="server" Text='<%# Bind("CATEGORY_CODE") %>'
Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Range" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblACTIVEFROM" runat="server" Text='<%# Bind("ACTIVE_FROM") %>' Visible="true"></asp:Label>  To  
<asp:Label ID="lblACTIVETO" runat="server" Text='<%# Bind("ACTIVE_TO") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Activity Type" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Actvity_Type" runat="server" Text='<%# Bind("ACTIVITY_TYPE") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Current Status" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lbl_Current_Status" runat="server" Text='<%# Bind("status") %>' Visible="true"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View Details" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<itemstyle width="5%" />
<asp:LinkButton CssClass="l_link" Text="View" ID="lnkView" runat="server" ToolTip="View" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-HorizontalAlign="Center">
<HeaderTemplate>
<asp:Label ID="lblCap" Text="Confirm" runat="server"></asp:Label>
</HeaderTemplate>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<itemstyle width="1%" font-size="2px" horizontalalign="Center" />
<table style="text-align: Center; vertical-align: text-top;">
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdYes" runat="server" Text="Yes" GroupName="CH"></asp:RadioButton></td>
</tr>
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdNo" runat="server" Text="No" GroupName="CH"></asp:RadioButton></td>
</tr>
<tr>
<td style="width: 98%;">
<asp:RadioButton ID="rdNone" runat="server" Text="None" GroupName="CH"></asp:RadioButton></td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle CssClass="tableRowHighlight" />
<RowStyle CssClass="odd_tb" />
<PagerStyle CssClass="foot_tbl" />
<AlternatingRowStyle CssClass="even_tb" />
<PagerSettings Mode="NextPreviousFirstLast" />
.js文件在下面给出
function view_Data(v_Act_Code) {
window.open("viewApprovalDetails.aspx?ACTCODE=" + v_Act_Code, 'ViewChange', 'height=440,width=650,left=150,top=150,screenX=0,screenY=100');
}
如何通过单击网格视图链接按钮打开新的弹出窗口 提前致谢
答案 0 :(得分:2)
在网格视图中,对于“链接”按钮,请使用如下所示的标记
<asp:LinkButton CssClass="l_link" Text="View" ID="lnkView" runat="server"
ToolTip="View" OnClientClick='<%#string.Format("return view_Data(\"{0}\");",
DataBinder.Eval(Container.DataItem, "ACTIVITY_CODE")) %>' />
在javascript中,从函数返回false,因此在linkbutton上单击postback不会发生
function view_Data(v_Act_Code) {
window.open("viewApprovalDetails.aspx?ACTCODE=" + v_Act_Code, 'ViewChange',
'height=440,width=650,left=150,top=150,screenX=0,screenY=100');
return false;
}
答案 1 :(得分:0)
在LinkButton
上绑定javascript点击事件。如果您不想要PostBack,请将ACTIVITY_CODE
传递给view_Data javascript函数并返回false
。
<asp:LinkButton CssClass="l_link" Text="View"
OnClientClick='view_Data(<%# Bind("ACTIVITY_CODE") %>); return false;'
ID="lnkView" runat="server" ToolTip="View" />
答案 2 :(得分:0)
试试这个
<asp:LinkButton CssClass="l_link" Text="View" ID="lnkView"
runat="server" ToolTip="View"
OnClientClick='javascript:return view_Data(<%# Bind("ACTIVITY_CODE") %>)' />
和JavaScript
function view_Data(v_Act_Code) {
window.open("viewApprovalDetails.aspx?ACTCODE=" + v_Act_Code, 'ViewChange', 'height=440,width=650,left=150,top=150,screenX=0,screenY=100');
//return false; if you don't want a postback
}
答案 3 :(得分:0)