Hi
I want to add a column to the RadGrid that contains a row counter. This has no data effect, and will only be used for reference and also as a drill-down button.
Is there an easier way than intercepting the ItemDataBound event and adding a column to each row?
I want to add a column to the RadGrid that contains a row counter. This has no data effect, and will only be used for reference and also as a drill-down button.
Is there an easier way than intercepting the ItemDataBound event and adding a column to each row?
4 Answers, 1 is accepted
0
CBARS
Top achievements
Rank 2
answered on 25 Sep 2008, 06:00 AM
What I've done is :
I have made my first column a hyperlink,
After the text is changed in the ItemDataBound event, the text in the column is no longer a hyperlink. Am I doing something wrong?
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
int i = 0; |
foreach (GridDataItem item in RadGrid1.Items) |
{ |
i++; |
item.Cells[2].Text = i.ToString(); |
} |
} |
I have made my first column a hyperlink,
<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="DrillDownPage.aspx?userid={0}" |
DataNavigateUrlFields="Userid" HeaderText="#"> |
</telerik:GridHyperLinkColumn> |
After the text is changed in the ItemDataBound event, the text in the column is no longer a hyperlink. Am I doing something wrong?
0
Hello cbars,
Please review the following help topic which will help you to acheive the required functionality.
Greetings,
Maria Ilieva
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please review the following help topic which will help you to acheive the required functionality.
Greetings,
Maria Ilieva
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
CBARS
Top achievements
Rank 2
answered on 29 Sep 2008, 12:04 PM
Hi Maria...
Thanks for the article... Looks like it will help. That approach doesn't work though when you have a dynamically generated dataset passed as datasource to the RadGrid, as well as having a detail table. Here's my code :
and the code-behind :
The grid shows, but whenever I try to expand one of the master table items, the RadGrid wants to fill the hplDrillDown on each detail row, which it doesn't find.
How can I check whether a row is a child of the master table view?
Thanks for the article... Looks like it will help. That approach doesn't work though when you have a dynamically generated dataset passed as datasource to the RadGrid, as well as having a detail table. Here's my code :
<telerik:RadGrid Settings="Here"> |
<Columns> |
<telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Row number"> |
<ItemTemplate> |
<asp:HyperLink id="hplDrillDown" runat="server" Text="" NavigateURL="" target="_blank" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
</telerik:RadGrid> |
and the code-behind :
if (e.Item is GridDataInsertItem) |
{ |
HyperLink hpl = e.Item.FindControl("hplDrillDown") as HyperLink; |
hpl.Text = (e.Item.ItemIndex + 1).ToString(); |
hpl.NavigateUrl = string.Format("~/Destination.aspx?userid={0}", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["UserID"].ToString()); |
} |
The grid shows, but whenever I try to expand one of the master table items, the RadGrid wants to fill the hplDrillDown on each detail row, which it doesn't find.
How can I check whether a row is a child of the master table view?
0
Accepted
Hi cbars,
Please refer to the following forum post which shows how to set this functionality for detail table.
All the best,
Maria Ilieva
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please refer to the following forum post which shows how to set this functionality for detail table.
All the best,
Maria Ilieva
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.