我有一个带有一些链接按钮的gridview。我想要做的是当我点击链接按钮时,将显示两个按钮,即(导出到CSV和导出到Excel)。 但是当我点击任何链接按钮时,什么也没发生...... 继承我的代码......
的GridView:
<asp:GridView ID="grd_ComplaintCount" runat="server" AutoGenerateColumns="False"
CellPadding="4" EnableModelValidation="True" ForeColor="#333333"
GridLines="None">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Total Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalComplaint" CommandName="Total"
Text='<%#Bind("TotalComplaint") %>' CommandArgument="Total"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Open Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalOpenComplaint" CommandName="Open"
Text='<%#Bind("TotalOpen") %>' CommandArgument="Open"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Closed Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalCloseComplaint" CommandName="Closed"
Text='<%#Bind("TotalClose") %>' CommandArgument="Closed"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Reassigned Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalReassignedComplaint" CommandName="Reassign"
Text='<%#Bind("TotalMemberReAssign") %>' CommandArgument="Reassigned"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Observation Complaint">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtn_TotalObservationComplaint" CommandName="Obeservation"
Text='<%#Bind("TotalObservation") %>' CommandArgument="Observation"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
这是我的代码..
Protected Sub grd_ComplaintCount_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grd_ComplaintCount.RowCommand
ComplaintCount_Detail(e.CommandArgument)
If e.CommandName = "Total" Or e.CommandName = "Open" Or e.CommandName = "Closed" Or e.CommandName = "Reassign" Or e.CommandName = "Obeservation" Then
btnexptocsv.Visible = True
btnexptoexcel.Visible = True
End If
End Sub
我知道我犯了一些错误......
答案 0 :(得分:0)
1.更改asp:LinkButton
标记并指定CommandName
commandname="Select" text='<%# Eval("MEO_NR") %>'>
2.创建RowCommandEvent
OnRowCommand="GVActiveMEOs_OnRowCommand"
代码隐藏
Protected Sub gridview1_RowCommand(sender As Object, e As GridViewCommandEventArgs)
Dim meonum As String = DirectCast(e.CommandSource, LinkButton).CommandArgument
End Sub
除非您将SelectedRow
指定为CommandName
CommandName="Select"