Hello,
I have a problem in using related comboboxex in radgrid editform.
Here is my code:
ItemsMngSubUserControl.acsx
ItemsMngSubUserControl.ascx.cs
In the above code, I'm trying to set different DataSourceID for
Please, I need your help,
It is apprecited to send me the modified code.
Regards,
Bader
I have a problem in using related comboboxex in radgrid editform.
Here is my code:
ItemsMngSubUserControl.acsx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ItemsMngSubUserControl.ascx.cs" Inherits="ItemsMngSubUserControl" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register src="~/SecureSiteManagenment/SecureSQLServer/Common/UserControls/JointUserControls/FileUrlUserControl/FileUrlFileSelectorUserControl.ascx" tagname="FileUrlFileSelectorUserControl" tagprefix="uc1" %>
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"../../../Common/Controls/RadEditor/RTLRadEditorStyle/Editor_RTL.css"
/>
<
style
type
=
"text/css"
>
.RightColumn
{
width:150px;
}
.LeftColumn
{
width:802px;
}
html
{
direction: rtl;
}
html, body, form
{
height: 100%;
margin: 0px;
padding: 0px;
}
/*info panel*/
.infoPanel,
.bigModule
{
border:1px solid #ffe58a;
margin:1.6em 0;
padding:1em 3em 1em 0;
background:#fff3c8 repeat-x url(../../../Common/styles09/infoPanel.gif);
color:#000;
}
.infoInner,
.bigModuleBottom
{
min-height:30px;
padding:0 0 0 66px;
background:no-repeat -1184px -1447px url(../../../Common/styles09/sprite09.gif);
}
.infoPanel .title,
.bigModule .title
{
display:block;
margin:0 0 1.4em;
padding:6px 0 0;
font-size:1.2em;
}
.infoPanel a,
.bigModule a
{
color:#f60;
}
</
style
>
<
div
style
=
"margin:10px;"
>
<
table
id
=
"Table2"
cellspacing
=
"2"
cellpadding
=
"1"
width
=
"100%"
border
=
"1"
rules
=
"none"
style
=
"BORDER-COLLAPSE: collapse"
>
<
tr
align
=
"right"
>
<
td
colspan
=
"2"
>
<
b
></
b
></
td
>
</
tr
>
<
tr
align
=
"right"
>
<
td
>
<
table
id
=
"Table3"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
colspan
=
"2"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:118px;"
>
<
asp:Label
ID
=
"ItmNameLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlItmNameLabel %>" ></
asp:Label
>
</
td
>
<
td
style
=
"width:834px;"
>
<
telerik:RadTextBox
ID
=
"ItmNameRadTextBox"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.ItmName" ) %>' Width="201px" >
</
telerik:RadTextBox
>
</
td
>
</
tr
>
</
table
>
<
telerik:RadAjaxPanel
ID
=
"CtgRadAjaxPanel"
runat
=
"server"
>
<
table
id
=
"Table1"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
style
=
"width:118px;"
>
<
asp:Label
ID
=
"MainCtgryLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlMainCtgryLabel %>"></
asp:Label
>
</
td
>
<
td
style
=
"width:834px;"
>
<
asp:XmlDataSource
ID
=
"MainCatgryXmlDataSource"
runat
=
"server"
DataFile
=
"~/Common/xml/HeaderMenu.xml"
XPath="Menu/Item[position() > 2]"></
asp:XmlDataSource
>
<
telerik:RadComboBox
ID
=
"MainCatgryRadComboBox"
Runat
=
"server"
DataSourceID
=
"MainCatgryXmlDataSource"
DataTextField
=
"IText"
EnableLoadOnDemand
=
"True"
AutoPostBack
=
"true"
OffsetX
=
"-30"
BorderColor
=
"Black"
BorderWidth
=
"1px"
HighlightTemplatedItems
=
"true"
Width
=
"206px"
Height
=
"150px"
DataValueField
=
"SubCtgry"
SelectedIndex='<%# (Convert.ToInt32(getMainCtgryIndexIndex(DataBinder.Eval( Container, "DataItem.MainCtgry" ).ToString().Trim()))) - 2 %>'
onselectedindexchanged="MainCatgryRadComboBox_SelectedIndexChanged" >
</
telerik:RadComboBox
>
<
asp:XmlDataSource
ID
=
"DfosSubCategoryXmlDataSource"
runat
=
"server"
DataFile
=
"~/Common/xml/DfosMenu.xml"
></
asp:XmlDataSource
>
<
asp:XmlDataSource
ID
=
"StudioSubCategoryXmlDataSource"
runat
=
"server"
DataFile
=
"~/Common/xml/StudioMenu.xml"
></
asp:XmlDataSource
>
<
asp:XmlDataSource
ID
=
"PrintingOnProductsSubCategoryXmlDataSource"
runat
=
"server"
DataFile
=
"~/Common/xml/PrintingOnProductsMenu.xml"
></
asp:XmlDataSource
>
<
asp:Label
ID
=
"SubCtgryDataLabel"
runat
=
"server"
Visible
=
"false"
Text='<%# DataBinder.Eval( Container, "DataItem.SubCtgry" ).ToString().Trim() %>'></
asp:Label
>
<
asp:Label
ID
=
"ESubCtgryDataLabel"
runat
=
"server"
Visible
=
"false"
ForeColor
=
"Red"
Text='<%# DataBinder.Eval( Container, "DataItem.ESubCtgry" ).ToString().Trim() %>'></
asp:Label
>
<
asp:Label
ID
=
"SDataLabel"
runat
=
"server"
Text
=
""
></
asp:Label
>
<
telerik:RadComboBox
ID
=
"SubCtgryRadComboBox"
runat
=
"server"
DataTextField
=
"IText"
DataValueField
=
"ItemID"
OffsetX
=
"-30"
BorderColor
=
"Black"
BorderWidth
=
"1px"
AutoPostBack
=
"true"
EnableLoadOnDemand
=
"True"
HighlightTemplatedItems
=
"true"
Width
=
"206px"
Height
=
"150px"
onselectedindexchanged
=
"SubCtgryRadComboBox_SelectedIndexChanged"
>
</
telerik:RadComboBox
>
<
asp:Button
ID
=
"DisplaySubCtgryButton"
Width
=
"120px"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlDisplaySubCtgryButtonText %>" visible='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? false : true %>' onclick="Button1_Click" />
</
td
>
</
tr
>
</
table
>
</
telerik:RadAjaxPanel
>
<
table
id
=
"Table4"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"100%"
border
=
"0"
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ViewItmLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlViewItmLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadComboBox
ID
=
"ViewItmRadComboBox"
Skin
=
"Vista"
Width
=
"205px"
BorderColor
=
"Black"
BorderWidth
=
"1px"
SelectedValue='<%# DataBinder.Eval( Container, "DataItem.ViewItm" ).ToString() %>' AutoPostBack="false"
runat="server" >
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxTrueText %>" Value="True" />
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxFalseText %>" Value="False" />
</
Items
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
runat
=
"server"
visible='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? false : true %>'>
<
td
colspan
=
"2"
>
</
td
>
</
tr
>
<
tr
runat
=
"server"
visible='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? false : true %>'>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"InsrtUserLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlInsrtUserLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
asp:Label
ID
=
"InsrtUserDataLabel"
runat
=
"server"
Text='<%# ((bool)DataBinder.Eval(Container, "OwnerTableView.IsItemInserted")) ? "" : TmonavotDB.GetUserNameByUserID(Convert.ToInt64(DataBinder.Eval( Container, "DataItem.LstUpdBy" ))) %>'></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
</
td
>
</
tr
>
<
tr
>
<
td
valign
=
"top"
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ItmDescLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlItmDescLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadTextBox
ID
=
"ItmDescRadTextBox"
TextMode
=
"MultiLine"
Rows
=
"4"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.ItmDesc" ) %>' Width="100%" >
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ViewItmBigDescLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlViewItmBigDescLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadComboBox
ID
=
"ViewItmBigDescRadComboBox"
Skin
=
"Vista"
Width
=
"205px"
BorderColor
=
"Black"
BorderWidth
=
"1px"
SelectedValue='<%# DataBinder.Eval( Container, "DataItem.ViewItmBigDesc" ).ToString() %>' AutoPostBack="false"
runat="server" >
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxFalseText %>" Value="False" />
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxTrueText %>" Value="True" />
</
Items
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"TitleLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlTitleLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadTextBox
ID
=
"TitleRadTextBox"
runat
=
"server"
Text='<%# DataBinder.Eval( Container, "DataItem.Title" ) %>' Width="201px" >
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
valign
=
"top"
>
<
asp:Label
ID
=
"ItmBigDescLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlItmBigDescLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
valign
=
"top"
>
<
telerik:RadEditor
runat
=
"server"
ID
=
"ItmBigDescRadEditor"
Height
=
"350px"
Width
=
"100%"
Content='<%# DataBinder.Eval( Container, "DataItem.ItmBigDesc") %>'
DialogsCssFile="~/Common/Controls/RadEditor/RTLRadEditorStyle/RadEditor_Dialogs_RTL.css" ContentAreaCssFile="~/Common/Controls/RadEditor/RTLRadEditorStyle/EditorContentArea_RTL.css">
<
Modules
>
<
telerik:EditorModule
Visible
=
"false"
/>
</
Modules
>
<
ImageManager
ViewPaths
=
"~/Pages/Design/Imgs/Itms"
DeletePaths
=
"~/Pages/Design/Imgs/Itms"
UploadPaths
=
"~/Pages/Design/Imgs/Itms"
/>
<
DocumentManager
ViewPaths
=
"~/Pages/Design/Imgs/Itms"
DeletePaths
=
"~/Pages/Design/Imgs/Itms"
UploadPaths
=
"~/Pages/Design/Imgs/Itms"
/>
<
MediaManager
ViewPaths
=
"~/Pages/Design/Imgs/Itms"
DeletePaths
=
"~/Pages/Design/Imgs/Itms"
UploadPaths
=
"~/Pages/Design/Imgs/Itms"
/>
</
telerik:RadEditor
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ViewPriceLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlViewPriceLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadComboBox
ID
=
"ViewPriceRadComboBox"
Skin
=
"Vista"
Width
=
"205px"
BorderColor
=
"Black"
BorderWidth
=
"1px"
SelectedValue='<%# DataBinder.Eval( Container, "DataItem.ViewPrice" ).ToString() %>' AutoPostBack="false"
runat="server" >
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxFalseText %>" Value="False" />
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxTrueText %>" Value="True" />
</
Items
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ItemPriceLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlItemPriceLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadNumericTextBox
ID
=
"ItemPriceRadNumericTextBox"
runat
=
"server"
DbValue='<%# DataBinder.Eval( Container, "DataItem.ItemPrice" ) %>' Width="201px" >
</
telerik:RadNumericTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ViewImgLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlViewImgLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
telerik:RadComboBox
ID
=
"ViewImgRadComboBox"
Skin
=
"Vista"
Width
=
"205px"
BorderColor
=
"Black"
BorderWidth
=
"1px"
SelectedValue='<%# DataBinder.Eval( Container, "DataItem.ViewImg" ).ToString() %>' AutoPostBack="false"
runat="server" >
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxTrueText %>" Value="True" />
<
telerik:RadComboBoxItem
runat
=
"server"
Text="<%$ Resources:Resource, TelerikTrueFalseRadComboBoxFalseText %>" Value="False" />
</
Items
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"RightColumn"
>
<
asp:Label
ID
=
"ImgUrlLabel"
runat
=
"server"
Text="<%$ Resources:Resource, SItemsMngSubUserControlImgUrlLabel %>"></
asp:Label
>
</
td
>
<
td
class
=
"LeftColumn"
>
<
uc1:FileUrlFileSelectorUserControl
ID
=
"FileUrlFileSelectorUserControl1"
runat
=
"server"
/>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"left"
colspan
=
"2"
>
<
asp:button
id
=
"btnUpdate"
text="<%$ Resources:Resource, TelerikRadGridEditFormUpdateButtonText %>" runat="server" CommandName="Update" Visible='<%# !(DataBinder.Eval( Container, "DataItem") is Telerik.Web.UI.GridInsertionObject) %>'></
asp:button
>
<
asp:button
id
=
"btnInsert"
text="<%$ Resources:Resource, TelerikRadGridEditFormInsertButtonText %>" runat="server" CommandName="PerformInsert" Visible='<%# DataBinder.Eval( Container, "DataItem") is Telerik.Web.UI.GridInsertionObject %>'></
asp:button
>
<
asp:button
id
=
"btnCancel"
text="<%$ Resources:Resource, TelerikRadGridEditFormCancelButtonText %>" runat="server" causesvalidation="False" commandname="Cancel"></
asp:button
></
td
>
</
tr
>
</
table
>
</
div
>
ItemsMngSubUserControl.ascx.cs
using System;
using System.Configuration;
using Telerik.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Web.UI.WebControls;
using System.Web;
using System.Data;
using System.Data.SqlClient;
public partial class ItemsMngSubUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
(FileUrlFileSelectorUserControl1.FindControl("TopicLabel") as Label).Text = "ItemsMng";
string eSubCtgry = string.Empty;
eSubCtgry = ESubCtgryDataLabel.Text.ToString().Trim();
string subCtgry = string.Empty;
subCtgry = SubCtgryDataLabel.Text.ToString().Trim();
RadComboBoxItem item = new RadComboBoxItem();
if (eSubCtgry.Contains("Dfos"))
{
SubCtgryRadComboBox.DataSourceID = "DfosSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox
.SelectedIndex = (Convert.ToInt32(getSubCtgryIndex(subCtgry, "Dfos")));
SubCtgryRadComboBox.Enabled = true;
}
else if (eSubCtgry.Contains("Studio"))
{
SubCtgryRadComboBox.DataSourceID = "StudioSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox
.SelectedIndex = (Convert.ToInt32(getSubCtgryIndex(subCtgry, "Studio")));
SubCtgryRadComboBox.Enabled = true;
}
else if (eSubCtgry.Contains("PrintingOnProducts"))
{
SubCtgryRadComboBox.DataSourceID = "PrintingOnProductsSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox
.SelectedIndex = (Convert.ToInt32(getSubCtgryIndex(subCtgry, "PrintingOnProducts")));
SubCtgryRadComboBox.Enabled = true;
}
}
protected void SubCtgryRadComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
SubCtgryDataLabel.Text = e.Text.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
SubCtgryRadComboBox.SelectedIndex = (Convert.ToInt32(getSubCtgryIndex(SubCtgryDataLabel.Text.ToString().Trim(), ESubCtgryDataLabel.Text.ToString().Trim())));
}
public string getMainCtgryIndexIndex(string _text)
{
string uu = string.Empty;
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/Common/xml/HeaderMenu.xml"));
XmlNodeList nodes = doc.SelectNodes("/Menu/Item");
foreach (XmlNode _uu in nodes)
{
foreach (XmlAttribute ss in _uu.Attributes)
{
if (ss.Name.Equals("IText"))
{
if (ss.Value.Equals(_text))
{
uu = Convert.ToString(_uu.Attributes[0].Value);
}
}
}
}
if (uu.Equals(string.Empty))
{
return "0";
}
else
{
return uu;
}
}
public string getSubCtgryIndex(string _text, string _subCtgry)
{
string uu = string.Empty;
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/Common/xml/" + _subCtgry + "Menu.xml"));
XmlNodeList nodes = doc.SelectNodes("/Menu/Item");
foreach (XmlNode _uu in nodes)
{
foreach (XmlAttribute ss in _uu.Attributes)
{
if (ss.Name.Equals("IText"))
{
if (ss.Value.Equals(_text))
{
uu = Convert.ToString(_uu.Attributes[0].Value);
}
}
}
}
if (uu.Equals(string.Empty))
{
return "0";
}
else
{
return uu;
}
}
protected void MainCatgryRadComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
string tt = e.Value.ToString().Trim();
if (tt.Contains("Dfos"))
{
SubCtgryRadComboBox.DataSourceID = "DfosSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox.Enabled = true;
SubCtgryRadComboBox.Text = "";
SubCtgryDataLabel.Text = Resources.Resource.SecureSecureSQLServerItemsMngSubCtgryText.ToString();
}
else if (tt.Contains("Studio"))
{
SubCtgryRadComboBox.DataSourceID = "StudioSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox.Enabled = true;
SubCtgryRadComboBox.Text = "";
SubCtgryDataLabel.Text = Resources.Resource.SecureSecureSQLServerItemsMngSubCtgryText.ToString();
}
else if (tt.Contains("PrintingOnProducts"))
{
SubCtgryRadComboBox.DataSourceID = "PrintingOnProductsSubCategoryXmlDataSource";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox.Enabled = true;
SubCtgryRadComboBox.Text = "";
SubCtgryDataLabel.Text = Resources.Resource.SecureSecureSQLServerItemsMngSubCtgryText.ToString();
}
else
{
SubCtgryRadComboBox.DataSourceID = "";
SubCtgryRadComboBox.DataBind();
SubCtgryRadComboBox.Enabled = false;
}
}
}
In the above code, I'm trying to set different DataSourceID for
SubCtgryRadComboBox
depending on MainCatgryRadComboBox Value and display SubCtgryRadComboBox
items (In Update mode, the selectedIndex must be displayed regarding the changes of SubCtgryRadComboBox
.Please, I need your help,
It is apprecited to send me the modified code.
Regards,
Bader