Hi, I want to use LINQ in the creation of heirarchy in radgrid, but to no avail, i can't solve.
Here is my snippet.
-------- .cs code-behind -----
// select from dropdownlist, then click button
protected void cmdView_Click(object sender, EventArgs e)
{
if (cmbItem.SelectedItem.Text != string.Empty)
{
this.radExpand.Rebind();
}
}
// itemID is being fetched from dropdownlist
void radExpand_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DataModelDataContext context = new DataModelDataContext();
if (cmbItem.SelectedItem.Text != string.Empty)
{
Guid teacherID = new Guid(cmbItem.SelectedValue);
var data = from d in context.inventoryItems where d.itemID== itemIDselect d;
this.radExpand.DataSource = data;
}
}
--------------------- .aspx markup -------------------------
<telerik:RadGrid runat="server" ID="radExpand" AllowPaging="True" GridLines="None" PageSize="30" AutoGenerateColumns="False" ShowFooter="True" ShowGroupPanel="false"
ShowStatusBar="True" OnNeedDataSource="radExpand_NeedDataSource" onitemcreated="radExpand_ItemCreated">
<MasterTableView>
<Columns>
<telerik:GridBoundColumn DataField="itemID" HeaderText="ID" UniqueName="itemID">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Item Name" UniqueName="itemName">
<ItemTemplate>
<%# myProject.getItemName(Convert.ToString(DataBinder.Eval(Container.DataItem, "itemID"))).ToUpper() %>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Status" HeaderText="Status">
<ItemTemplate>
<%# myProject.getStatus(new Guid(Convert.ToString(DataBinder.Eval(Container.DataItem, "itemID")))) %>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
-----------------------------------------
Thank you.