I placed a grid on a form, added datasource, data is displayed properly. User selects a row and clicks some link button.Inside my code behind I would like to get access to selected row.But my_grid.Behaviors.Selection.SelectedRows.Count = 0.What is wrong with my code?
Grid:
<ig1:WebHierarchicalDataGrid ID="my_grid" runat="server" AutoGenerateBands="False" AutoGenerateColumns="False" DataKeyFields="ID" DataMember="ObjectDataSourceKlasy_DefaultView" DataSourceID="KlasyDataSource" Height="350px" Key="ObjectDataSourceKlasy_DefaultView" Width="400px"> <Bands> <ig1:Band AutoGenerateColumns="False" DataMember="ObjectDataSourceDaneKlas_DefaultView" Key="ObjectDataSourceDaneKlas_DefaultView"> <Columns> //... </Columns> </ig1:Band> </Bands> <Columns> </Columns> <Behaviors> <ig1:Activation> </ig1:Activation> <ig1:EditingCore> <Behaviors> <ig1:CellEditing> </ig1:CellEditing> </Behaviors> </ig1:EditingCore> <ig1:Paging> </ig1:Paging> <ig1:RowSelectors> </ig1:RowSelectors> <ig1:Selection RowSelectType="Single"> </ig1:Selection> <ig1:Sorting> </ig1:Sorting> </Behaviors> </ig1:WebHierarchicalDataGrid>
Hello Arthur,On which event you are trying to get the selected row? When you make a postback this collection will be empty till the load phase is over. Our grid should be fully loaded with data and then if you like to access the collection in PreRender event it should be filled with all the rows and row count should be the expected one.
I do that on event of clicking link button -> protected void button_Click(object sender, EventArgs e)