I have used the example in MultiColumn Combo to make the RADComboBox work with LINQ. I cannot extend the example to show the records in a related table which is used as a lookup.
Have two tables:
Parent [table1] - List of records [parentfield1 and parentfield2] parentfield2 links to childfield1 in table2
Child [table2] - List of related records by parentfield2 to childfield1 [want to show these records in the ComboBox...childfield1 and childfield2]
What is described below does work in a fashion. It only lists the key field in table 1 (parentfield1).
Code is as follows:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server"><title>Untitled Page</title></head>
<
body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px" width="784px">
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticUpdates="True" AllowPaging="True" AllowSorting="True" AutoGenerateEditColumn="True" DataMember="DefaultView" DataSourceID="LinqDataSource1" GridLines="None" Skin="Mac">
<ExportSettings><Pdf FontType="Subset" PaperSize="Letter" /><Excel Format="Html" /><Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" /></ExportSettings>
<MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" CurrentResetPageIndexAction="SetPageIndexToFirst" DataMember="DefaultView" DataSourceID="LinqDataSource1" Dir="LTR" Frame="Border" TableLayout="Auto" DataKeyNames="ParentField1">
<RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn>
<ExpandCollapseColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType" Resizable="False" Visible="False"> <HeaderStyle Width="20px" /></ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ParentField1" DataType="System.Int32" FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="ParentField1" ReadOnly="True" SortExpression="ParentField1" UniqueName="ParentField1"> </telerik:GridBoundColumn>
<telerik:GridTemplateColumn CurrentFilterFunction="NoFilter" DataField="ParentField2" FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="ParentField2" SortExpression="ParentField2" UniqueName="ParentField2">
<EditItemTemplate> <telerik:RadComboBox ID="RadComboBox1" Runat="server" DataSourceID="LinqDataSource1" Height="100px" RadComboBoxImagePosition="Right" SelectedValue='<%# Bind("ParentField2") %>' Skin="Mac" Width="208px" EnableLoadOnDemand="true" DataTextField="ParentField2" DataValueField="ParentField2" OnItemsRequested="RadComboBox1_ItemsRequested">
<CollapseAnimation Duration="200" Type="OutQuint" />
<ExpandAnimation Type="OutQuart" />
</telerik:RadComboBox>
</EditItemTemplate>
<ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ParentField2") %>'> </asp:Label> </ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings>
<EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
</EditColumn>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" height="75px" width="75px"> <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0px;" /> </telerik:RadAjaxLoadingPanel>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DataClassesDataContext" EnableUpdate="True" TableName="Table1"> </asp:LinqDataSource>
</telerik:RadAjaxPanel>
</div>
</form>
</
body>
</
html>
Default.aspx.cs
using
System; using System.Configuration; using System.Data; using System.Linq; using system.Web; using System.Web.Security; using System.Web.UI; using system.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.IO; using Telerik.Web.UI; using System.Collections;
public
partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { }
protected void RadComboBox1_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
var initstatus = from s in db.table2
group s by s.childfield1 into x
select new { field1 = x.Key, field2 = x };
RadComboBox combobox = (RadComboBox)sender;
combobox.Items.Clear();
foreach(var table2 in initstatus)
{
RadComboBoxItem item = new RadComboBoxItem();
combobox.Items.Add(item);
} } }
| Dim scriptstring As String = "radalert('<b>" + Message + "</b>!', 200, 210, '" + messageType.ToString + "');" | |
| ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "radalert", scriptstring, True) |

<
telerik:RadGrid ID="rgEditGrid" ........ </telerik:RadGrid>
<
asp:PlaceHolder ID="phError" runat="server"></asp:PlaceHolder>
Error description:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: key
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Hi everyone,
I have a problem with ServerSideCallback. I want to modify some properties of the node which fired the NodeExpand event in the same one.
| protected void RadTreeView1_NodeExpand(object sender, RadTreeNodeEventArgs e) |
| { |
| IList<EntityTypeDataContract> list = GetList(e); |
| if (list.Count > 0) |
| { |
| foreach (EntityTypeDataContract type in list) |
| { |
| RadTreeNode treeNode = new RadTreeNode(type.DisplayName, type.Value); |
| treeNode.Expanded = false; |
| treeNode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; |
| e.Node.Nodes.Add(treeNode); |
| } |
| } |
| else |
| { |
| e.Node.Expanded = false; |
| e.Node.ExpandMode = TreeNodeExpandMode.ClientSide; |
| } |
| } |