Sar*_*nyu 7 c# asp.net gridview devexpress rowcommand
我已经找到了解决方案,我只想发布它,这对某些人来说可能有用
这是使用命令的按钮
<dxwgv:ASPxGridView ID="gdvxUsers" runat="server" AutoGenerateColumns="False" Width="100%" KeyFieldName="UserName" onrowcommand="gdvxUsers_RowCommand">
<Columns>
<dxwgv:GridViewDataTextColumn Caption="Edit" VisibleIndex="0" Width="0px">
<DataItemTemplate>
<asp:ImageButton ID="imbEdit" runat="server"
CommandName = "Edit"
ImageUrl="~/images/icon/Edit-icon.png" ClientIDMode="Static" />
</DataItemTemplate>
</dxwgv:GridViewDataTextColumn>
</dxwgv:ASPxGridView>
Run Code Online (Sandbox Code Playgroud)
protected void gdvxUsers_RowCommand(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewRowCommandEventArgs e)
{
switch (e.CommandArgs.CommandName)
{
case "Edit":
break;
}
}
Run Code Online (Sandbox Code Playgroud)
单击按钮时,行命令不会触发.
Sar*_*nyu 10
问题是,Page_Load我Databind()在gridview 上使用命令我正在使用rowcommand,似乎之后DataBind(),rowcommand取消了.
protected void Page_Load(object sender, EventArgs e)
{
gdvxUsers.DataSource = GetAllUserAndRole();
gdvxUsers.DataBind();
}
Run Code Online (Sandbox Code Playgroud)
所以我通过仅在第一次加载时绑定数据来解决此问题.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
gdvxUsers.DataSource = GetAllUserAndRole();
gdvxUsers.DataBind();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17215 次 |
| 最近记录: |