hi there,
Please help me to setup my RadGrid.
My scenario is : I click on a linkbutton with a navigateUrl which contains parameters I need to Load the RadGrid. With that parameter, I can load my list of Entities.
But the visual representation of theses datas, is not a classical RadGrid with properties columns binding.
In fact, I need to Bind each Entity into a Cell of my RadGrid. How can I realise it ?
I am trying this code :
public void Loading()
{
List<T> entities = getFromDb(); // T is my complex Object
// Determine what will be the rows
List<string> rows = entities.Select(e => e.X_MyProperty).Distinct().ToList();
// Determine what will be the columns
List<string> columns = entities.Select(e => e.Y_MyProperty).Distinct().ToList();
DataTable table = new DataTable();
table.Columns.Add("FirstColumn");
foreach (string columnsName in columns)
{
table.Columns.Add(columnsName);
}
foreach (var row in rows)
{
TableRow r = new TableRow();
table.Rows.Add(r);
r.Cells.Add(new TableCell {Text = row });
for (int i = 0; i < columns.Count; i++)
{
var c = new TableCell();
r.Cells.Add(c);
c.Controls.Add(new Label { Text = "A Property of T to display" });
}
}
GridDetailEmplacements.DataSource = table;
GridDetailEmplacements.DataBind();
}
Inside the ASPX file :
<telerik:RadGrid runat="server" ID="GridDetailEmplacements" AutoGenerateColumns="False">
<ClientSettings ReorderColumnsOnClient="false" AllowColumnsReorder="false">
<Selecting AllowRowSelect="false" EnableDragToSelectRows="false" />
<Resizing AllowColumnResize="false" ResizeGridOnColumnResize="false" AllowResizeToFit="false" />
</ClientSettings>
<HeaderStyle HorizontalAlign="Center" Font-Size="14px"></HeaderStyle>
<ItemStyle HorizontalAlign="Left" Font-Names="Arial Unicode MS" Font-Size="12px" />
<AlternatingItemStyle HorizontalAlign="Left" Font-Names="Arial Unicode MS" Font-Size="12px" />
</telerik:RadGrid>
How can I Bing different properties of my Object of T inside each cells ?
I would like render acell with a simple asp:Table which contains 3 rows with 3 properties of my Object
Thank's for helping
Best regards