2012-11-07 42 views
2

我有gridview,我在运行时使用datatable添加行作为datasource.but我想添加删除命令字段到网格view.I添加并运行它。但我有删除按钮在左侧position.I想改变删除按钮提前到最后自动生成columns.Please帮助me.Thanks后gridview.Means的如何将自动生成的列移动到左侧?

+0

你试过了什么? –

回答

0

这次调职,你需要知道把你生成列在最左边的部分是什么:

Move AutoGenerate Columns at LeftMost Part of the GridView Columns

+0

谢谢你。这是非常有用的 –

+0

虽然这可能在理论上回答这个问题,[这将是更可取的](http://meta.stackexchange.com/q/8259)在这里包括答案的基本部分,并提供该链接供参考。 –

0

您可以通过执行以下操作更改订单: -

YourDataColumn.SetOrdinal(0); 

这使您可以将列移动到无效位置。

希望这会有所帮助。

0
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){ 

     GridViewRow row = e.Row; 
     // Intitialize TableCell list 
     List<TableCell> columns = new List<TableCell>(); 
     foreach (DataControlField column in GridView1.Columns) 
     { 
      if (row.Cells.Count > 0) 
      { 
      //Get the first Cell /Column 
      TableCell cell = row.Cells[0]; 
      // Then Remove it after 
      row.Cells.Remove(cell); 
      //And Add it to the List Collections 
      columns.Add(cell); 
      } 
     } 

     // Add cells 
     row.Cells.AddRange(columns.ToArray()); 
} 
相关问题