【问题标题】:devexpress ASPxGridView column problemdevexpress ASPxGridView 列问题
【发布时间】:2010-05-16 03:39:16
【问题描述】:

我有一个绑定到 SQL 查询的 ASPXGRIDVIEW。 我在网格中添加了一个额外的 COLUMNCUSTOMBUTTON。 但是发生的情况是,对于所有行,它都会在那里放置一个链接。 我正在尝试找到一种方法来将此列添加到仅特定行的链接(按钮)!

我不明白该怎么做

谢谢

【问题讨论】:

    标签: c# asp.net devexpress


    【解决方案1】:

    要添加自定义按钮,请将其添加到 aspx 端的命令列中:

     <dxwgv:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="AccessDataSource1" KeyFieldName="EmployeeID" AutoGenerateColumns="False" Width="100%" OnCustomButtonCallback="grid_CustomButtonCallback" OnInitNewRow="grid_InitNewRow">
         <Columns>
             <dxwgv:GridViewCommandColumn VisibleIndex="0">
                 <EditButton Visible="True" />
                 <NewButton Visible="True" />
                 <CustomButtons>
                     <dxwgv:GridViewCommandColumnCustomButton Text="Create a Copy" ID="Copy" />
                 </CustomButtons>
             </dxwgv:GridViewCommandColumn>
    

    然后在你的代码隐藏中:

    public partial class GridEditing_EditForm : BasePage {
     protected void Page_Load(object sender, EventArgs e) {
    
     }
    
     Hashtable copiedValues = null;
     string[] copiedFields = new string[] { "FirstName", "Title", "Notes", "LastName", "BirthDate", "HireDate" };
     protected void grid_CustomButtonCallback(object sender, ASPxGridViewCustomButtonCallbackEventArgs e) {
         if(e.ButtonID != "Copy") return;
         copiedValues = new Hashtable();
         foreach(string fieldName in copiedFields) {
             copiedValues[fieldName] = grid.GetRowValues(e.VisibleIndex, fieldName);
         }
         grid.AddNewRow();
    
     }
     protected void grid_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) {
         if(copiedValues == null) return;
         foreach(string fieldName in copiedFields) {
             e.NewValues[fieldName] = copiedValues[fieldName];
         }
     }
    }
    

    您可以在此处查看完整的演示: http://demos.devexpress.com/ASPxGridViewDemos/Columns/CommandColumnCustomButtons.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多