4 Answers, 1 is accepted
0
Kevin Babcock
Top achievements
Rank 1
answered on 16 Nov 2008, 07:22 AM
Hello Joe,
If all you want is the header text for your cells, then you can simply iterate through the columns of the RadGrid and retrieve their header text values. All cells in a column will have the same header text value.
Here is a simple way to do that after the RadGrid.OnDataBound event is fired (which occurs after the data source has been bound to the grid):
I hope this helps. If you have further questions please let me know.
Regards,
Kevin Babcock
If all you want is the header text for your cells, then you can simply iterate through the columns of the RadGrid and retrieve their header text values. All cells in a column will have the same header text value.
Here is a simple way to do that after the RadGrid.OnDataBound event is fired (which occurs after the data source has been bound to the grid):
protected void RadGrid1_DataBound(object sender, EventArgs e) |
{ |
foreach (Telerik.Web.UI.GridColumn column in RadGrid1.Columns) |
{ |
var headerText = column.HeaderText; |
// Put the rest of your logic here... |
} |
} |
I hope this helps. If you have further questions please let me know.
Regards,
Kevin Babcock
0
jfkrueger
Top achievements
Rank 1
answered on 16 Nov 2008, 07:08 PM
Thanks, that helps but I still need to be able to do it as I am iterating through the grid. Here is what I have come up with so far but there are still problems:
Here I am trying to grab the last row in the gridview, iterate through the cells to find out which cells have checkboxes (i removed the code where I am trying to find the checkboxes because I need to get past this issue first) in them and then to find the header text of these cells so I know which type of coverage it represents (medical, dental, vision etc.) and finally to determine if the checkbox was checked. The grid is created dynamically and could have any number of combinations for coverages offered so I can't count on it always having the same structure.
The problem with the above code is that somehow there are more cells in this row then there are columns in the grid. I don't know why but for some reason it says that there are 8 cells in the row but only 6 columns in the grid, so I get an argument out of range exception.
Thanks again!
If rgCoverages.Items.Count > 0 Then |
gvRow = rgCoverages.items(rgCoverages.Items.Count - 1) |
For Each myCell As Telerik.Web.UI.GridTableCell In gvRow.Cells |
strHeader = rgCoverages.Columns(intCellIndex).HeaderText |
intCellIndex += 1 |
Next |
End If |
Here I am trying to grab the last row in the gridview, iterate through the cells to find out which cells have checkboxes (i removed the code where I am trying to find the checkboxes because I need to get past this issue first) in them and then to find the header text of these cells so I know which type of coverage it represents (medical, dental, vision etc.) and finally to determine if the checkbox was checked. The grid is created dynamically and could have any number of combinations for coverages offered so I can't count on it always having the same structure.
The problem with the above code is that somehow there are more cells in this row then there are columns in the grid. I don't know why but for some reason it says that there are 8 cells in the row but only 6 columns in the grid, so I get an argument out of range exception.
Thanks again!
0
Accepted
Hello Joe,
Please use RenderColumn collection instead Columns.
Kind regards,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please use RenderColumn collection instead Columns.
Kind regards,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
jfkrueger
Top achievements
Rank 1
answered on 17 Nov 2008, 05:27 PM
Ok, got it to work using MasterTableView.RenderColumns collection.
Thanks!
Thanks!