简体   繁体   English

devexpress ASPxGridView列问题

[英]devexpress ASPxGridView column problem

I have an ASPXGRIDVIEW which is binded to an SQL query. 我有一个绑定到SQL查询的ASPXGRIDVIEW。 I added to the grid an additional COLUMNCUSTOMBUTTON. 我在网格中添加了其他的COLUMNCUSTOMBUTTON。 But what happens is, that for all the rows it put a link there. 但是发生的是,对于所有行,它都在其中放置了一个链接。 I am trying to find a way to add to this column a link (button) ONLY to specific rows! 我正在尝试找到一种仅向特定行添加链接(按钮)的方法!

I am unable to understand how to do it 我不知道该怎么做

thanks 谢谢

To add a custom button, add this to your command column in the aspx side: 要添加自定义按钮,请将其添加到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>

Then in your codebehind: 然后在您的代码背后:

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];
     }
 }
}

You can see the full demo here: http://demos.devexpress.com/ASPxGridViewDemos/Columns/CommandColumnCustomButtons.aspx 您可以在此处查看完整的演示: http : //demos.devexpress.com/ASPxGridViewDemos/Columns/CommandColumnCustomButtons.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM