Reputation: 3982
I have an ASPxGridView with a command column:
<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>
The ObjectDataSource backing this grid has a set of Objects with a 'Selected' property, some set to true. How can I data bind the 'selected rows'?
Thank you
Ryan
Upvotes: 0
Views: 2792
Reputation: 3982
Found this from DevX site (eventually...)
There is no need to use the HtmlRowCreated event for this purpose. It is better to implement this feature in the DataBount event handler of the ASPxGridView:
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);
}
Upvotes: 4