2011-09-06 19 views
0

我有一个ASPxGridView用命令列:绑定Developer Express公司ASPxGridView命令(选择)列

<Columns> 
    <dx:GridViewCommandColumn Caption="#" ShowSelectCheckbox="True" VisibleIndex="1" Width="30" >  
     <HeaderTemplate> 
      <!-- The javascript function is set in the code behind (has to get dynamic grid name) --> 
      <dx:ASPxCheckBox ID="SelectAllCheckBox" runat="server" ToolTip="Select/Unselect all rows on the page" %>' /> 
     </HeaderTemplate> 
    </dx:GridViewCommandColumn> 

ObjectDataSource控件支持此电网有一个“选择”属性,一些设置为true一组对象。我如何将数据绑定到“选定的行”?

谢谢

瑞安

回答

3

从DevX网站(最终...)

没有必要使用HtmlRowCreated事件为此找到的。最好在ASPxGridView的DataBount事件处理程序中实现此功能:

protected void ASPxGridView1_DataBound(object sender, EventArgs e) { 
    ASPxGridView grid = sender as ASPxGridView; 
    for(int i = 0;i < grid.VisibleRowCount;i++) 
     if(Convert.ToInt32(grid.GetRowValues(i, new string[] { "CategoryID" })) % 2 == 0) 
      grid.Selection.SelectRow(i); 
} 
+1

很好的解决方案:) – Mikhail