将两个按钮列添加到 .NET Web 应用程序 telerik 网格视图
Add two button columns to .NET web application telerik grid view
我在 .NET 网络项目中使用 'telerik grid view'。我在其中使用了两个 'Grid Button Columns'。 Default.aspx中的代码如下
<telerik:RadGrid ID="testGrid" runat="server" AutoGenerateColumns="false" GridLines="None">
<MasterTableView DataKeyNames="userID" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true" PagerStyle-Mode="NextPrevNumericAndAdvanced">
<RowIndicatorColumn Visible="false">
<HeaderStyle Width="20" />
</RowIndicatorColumn>
<ExpandCollapseColumn Resizable="false" Visible="false">
<HeaderStyle Width="20" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn HeaderStyle-Width="70px" DataField="SuserID" HeaderText="User ID"></telerik:GridBoundColumn>
</Columns>
<Columns >
<telerik:GridBoundColumn DataField="userName" HeaderText="User Name"></telerik:GridBoundColumn>
</Columns>
<Columns >
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select">
</telerik:GridButtonColumn>
</Columns>
<Columns>
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test 2" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select">
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
最后我在 Default.aspx.vb 文件中包含了以下代码,
Protected Sub testGrid_ItemCommand(source As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles testGrid.ItemCommand
PoupMessage("testing confiremed !")
End Sub
现在,当我单击网格视图中的两个按钮列时,会弹出相同的消息。我想为相关按钮分配两个任务。我该怎么做?
如果我没理解错的话
将代码更改为 CommandName
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select1">
</telerik:GridButtonColumn>
</Columns>
<Columns>
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test 2" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select2">
</telerik:GridButtonColumn>
</Columns>
并且在 ItemCommand
事件中
If e.CommandName = "SELECT1 " Then
//some code
ElseIf e.CommandName = "SELECT2 " Then
//some code
End If
我在 .NET 网络项目中使用 'telerik grid view'。我在其中使用了两个 'Grid Button Columns'。 Default.aspx中的代码如下
<telerik:RadGrid ID="testGrid" runat="server" AutoGenerateColumns="false" GridLines="None">
<MasterTableView DataKeyNames="userID" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true" PagerStyle-Mode="NextPrevNumericAndAdvanced">
<RowIndicatorColumn Visible="false">
<HeaderStyle Width="20" />
</RowIndicatorColumn>
<ExpandCollapseColumn Resizable="false" Visible="false">
<HeaderStyle Width="20" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn HeaderStyle-Width="70px" DataField="SuserID" HeaderText="User ID"></telerik:GridBoundColumn>
</Columns>
<Columns >
<telerik:GridBoundColumn DataField="userName" HeaderText="User Name"></telerik:GridBoundColumn>
</Columns>
<Columns >
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select">
</telerik:GridButtonColumn>
</Columns>
<Columns>
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test 2" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select">
</telerik:GridButtonColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
最后我在 Default.aspx.vb 文件中包含了以下代码,
Protected Sub testGrid_ItemCommand(source As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles testGrid.ItemCommand
PoupMessage("testing confiremed !")
End Sub
现在,当我单击网格视图中的两个按钮列时,会弹出相同的消息。我想为相关按钮分配两个任务。我该怎么做?
如果我没理解错的话
将代码更改为 CommandName
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select1">
</telerik:GridButtonColumn>
</Columns>
<Columns>
<telerik:GridButtonColumn HeaderStyle-Width="30px" HeaderText="Test 2" Text="<img src=images\edit1.gif border=0 align=absmiddle alt='Select this Item'>"
CommandName="Select2">
</telerik:GridButtonColumn>
</Columns>
并且在 ItemCommand
事件中
If e.CommandName = "SELECT1 " Then
//some code
ElseIf e.CommandName = "SELECT2 " Then
//some code
End If