Hi Telerik Team,
I have a RadGrid requirement that needs "InPlace" Editmode in which there need to be two dropdown columns one depends on other dropdown selection...
so i have seen a example in your site
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/validation/defaultcs.aspx
in this example when "Adding new Record" can i load data in second "Dropdownlist" depending on the first "Dropdownlist" selected value.
If so what is the best template column i can use to have an access on Dropdownlists.
Can u please guide me with correct approach how to obtain this requirement.
Its urgent...Please do respond
Thanks in Advance
I have a RadGrid requirement that needs "InPlace" Editmode in which there need to be two dropdown columns one depends on other dropdown selection...
so i have seen a example in your site
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/validation/defaultcs.aspx
in this example when "Adding new Record" can i load data in second "Dropdownlist" depending on the first "Dropdownlist" selected value.
If so what is the best template column i can use to have an access on Dropdownlists.
Can u please guide me with correct approach how to obtain this requirement.
Its urgent...Please do respond
Thanks in Advance
4 Answers, 1 is accepted
0
Hello Nani,
The project in the code library below shows how to use related RadComboBoxes for Insert and Update operations in RadGrid:
http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in-radgrid.aspx
Give it a try and see if it works as you expected.
All the best,
Pavlina
the Telerik team
The project in the code library below shows how to use related RadComboBoxes for Insert and Update operations in RadGrid:
http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in-radgrid.aspx
Give it a try and see if it works as you expected.
All the best,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 08:04 PM
HI Pavlina,
It almost worked and i have one more concern of setting the "Combobox value" to the label text when i hit "Edit button". I am attaching code and also the snipshot how its behaving...
And more concern is when i hit "Add new record" i have a required field validators for the columns and "Source Breakdown*" combobox should reflect according to the "Source*" combobox but before firing the "Selectionchanged event its firing "validators" and "Selection change event is not firing.
*Find in snipshots attached
---ASPX code for columns----
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
>
<
HeaderStyle
Width
=
"20px"
/>
<
ItemStyle
CssClass
=
"MyImageButton"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"SortOrder"
HeaderText
=
"Sort Order"
SortExpression
=
"SortOrder"
UniqueName
=
"SortOrder"
HeaderStyle-Width
=
"25px"
ItemStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"QueueName"
HeaderText
=
"Queue Name"
SortExpression
=
"QueueName"
UniqueName
=
"QueueName"
HeaderStyle-Width
=
"230px"
ItemStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PhoneNumber"
HeaderText
=
"Phone Number"
SortExpression
=
"PhoneNumber"
UniqueName
=
"PhoneNumber"
HeaderStyle-Width
=
"100px"
ItemStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Source"
UniqueName
=
"SourceName"
HeaderStyle-Width
=
"200px"
ItemStyle-HorizontalAlign
=
"Left"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblsource"
runat
=
"server"
></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbsource"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"cmbsource_SelectedIndexChanged"
Height
=
"150px"
>
</
telerik:RadComboBox
>
<
asp:RequiredFieldValidator
ID
=
"validator3"
runat
=
"server"
ControlToValidate
=
"cmbsource"
Display
=
"Dynamic"
ErrorMessage
=
"*Required"
ForeColor
=
"Red"
>
</
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Source Breakdown"
UniqueName
=
"SourceBreakdown"
HeaderStyle-Width
=
"200px"
ItemStyle-HorizontalAlign
=
"Left"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblbreakdown"
runat
=
"server"
></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbbreakdown"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Active"
DataField
=
"Active"
UniqueName
=
"Active"
HeaderStyle-Width
=
"40px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblActive"
runat
=
"server"
Text='<%# Convert.ToBoolean(Eval("Active"))==true ? "No" : "Yes"%>'></
asp:Label
></
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbactive"
runat
=
"server"
Text= '<%# Bind("Active") %>'>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
""
Value
=
""
/>
<
telerik:RadComboBoxItem
Text
=
"Yes"
Value
=
"False"
/>
<
telerik:RadComboBoxItem
Text
=
"No"
Value
=
"True"
/>
</
Items
>
</
telerik:RadComboBox
>
<
asp:RequiredFieldValidator
ID
=
"validator4"
runat
=
"server"
ControlToValidate
=
"cmbactive"
Display
=
"Dynamic"
ErrorMessage
=
"*Required"
ForeColor
=
"Red"
>
</
asp:RequiredFieldValidator
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
Code behind which shows setting text in "Label" and binding values in "Combobox"
protected
void
rgQueue_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
int
index = e.Item.ItemIndex;
Label textsource = (Label)e.Item.FindControl(
"lblsource"
);
Label textbreak = (Label)e.Item.FindControl(
"lblbreakdown"
);
using
(EnabledDataContext db =
new
EnabledDataContext())
{
var queues = (from queue
in
db.Queues
where queue.StoreID.Equals(535)
select
new
{
Queue = queue.Queue1,
SortOrder = queue.SortOrder,
QueueName = queue.Media,
PhoneNumber = queue.PhoneNumber,
SourceID = queue.SourceID,
SourceBreakdownID = queue.SourceBreakdownID,
Active = queue.Deleted
}).OrderBy(a => a.SortOrder).ThenBy(a => a.QueueName).ToList();
var sources = (from source
in
db.Sources
where source.SourceID == queues.ElementAt(index).SourceID &&
source.StoreID == 535
select
new
{
SourceID = source.SourceID,
SourceName = source.SourceName
}).OrderBy(a => a.SourceName).ToList();
var breakdowns = (from sourcebreakdown
in
db.SourceBreakdowns
where sourcebreakdown.SourceBreakdownID == queues.ElementAt(index).SourceBreakdownID &&
sourcebreakdown.StoreID == 535
select
new
{
SourceBreakdownID = sourcebreakdown.SourceBreakdownID,
BreakdownValue = sourcebreakdown.BreakdownValue
}).OrderBy(a => a.BreakdownValue).ToList();
if
(sources.Count != 0) { textsource.Text = sources.ElementAt(0).SourceName; }
else
{ textsource.Text =
"Selected by user"
; }
if
(breakdowns.Count != 0) { textbreak.Text = breakdowns.ElementAt(0).BreakdownValue; }
else
{ textbreak.Text =
"Selected by user"
; }
}
}
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
int
index = e.Item.ItemIndex;
GridEditableItem editableitem = e.Item
as
GridEditableItem;
RadComboBox listsource = (RadComboBox)e.Item.FindControl(
"cmbsource"
);
RadComboBox listbreakdown = (RadComboBox)e.Item.FindControl(
"cmbbreakdown"
);
using
(EnabledDataContext db =
new
EnabledDataContext())
{
var queues = (from queue
in
db.Queues
where queue.StoreID.Equals(535)
select
new
{
Queue = queue.Queue1,
SortOrder = queue.SortOrder,
QueueName = queue.Media,
PhoneNumber = queue.PhoneNumber,
SourceID = queue.SourceID,
SourceBreakdownID = queue.SourceBreakdownID,
Active = queue.Deleted
}).OrderBy(a => a.SortOrder).ThenBy(a => a.QueueName).ToList();
var sources = (from source
in
db.Sources
where source.StoreID == 535 && !source.Deleted
select
new
{
SourceID = source.SourceID.ToString(),
SourceName = source.SourceName
}).OrderBy(a => a.SourceName).ToList();
sources.Insert(0,
new
{ SourceID =
""
, SourceName =
"Selected by user"
});
if
(index >= 0 && index <= queues.Count)
{
var breakdowns = (from sourcebreakdown
in
db.SourceBreakdowns
where sourcebreakdown.SourceBreakdownID == queues.ElementAt(index).SourceBreakdownID ||
sourcebreakdown.SourceID == queues.ElementAt(index).SourceID && !sourcebreakdown.Deleted
select
new
{
SourceBreakdownID = sourcebreakdown.SourceBreakdownID.ToString(),
BreakdownValue = sourcebreakdown.BreakdownValue
}).OrderBy(a => a.BreakdownValue).ToList();
breakdowns.Insert(0,
new
{ SourceBreakdownID =
""
, BreakdownValue =
"Selected by user"
});
listbreakdown.DataSource = breakdowns;
listbreakdown.DataTextField =
"BreakdownValue"
;
listbreakdown.DataValueField =
"SourceBreakdownID"
;
listbreakdown.DataBind();
listbreakdown.Items.FindItemByText(
"Selected by user"
).ForeColor = Color.Red;
}
listsource.DataSource = sources;
listsource.DataTextField =
"SourceName"
;
listsource.DataValueField =
"SourceID"
;
listsource.DataBind();
listsource.Items.FindItemByText(
"Selected by user"
).ForeColor = Color.Red;
if
(editableitem.ItemIndex > -1)
{
if
(!
string
.IsNullOrEmpty(Convert.ToString(editableitem.GetDataKeyValue(
"SourceName"
))))
{
listsource.SelectedValue = Convert.ToString(editableitem.GetDataKeyValue(
"SourceName"
));
}
}
}
}
}
Code behind for "Validators" and "Selection changed event"
protected
void
cmbsource_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox rcsource = (sender
as
RadComboBox);
GridEditableItem editItem = (GridEditableItem)rcsource.NamingContainer;
RadComboBox rcsourcebreakdown = (RadComboBox)editItem[
"SourceBreakdown"
].FindControl(
"cmbbreakdown"
);
string
value = rcsource.SelectedValue;
using
(EnabledDataContext db =
new
EnabledDataContext())
{
var queues = (from queue
in
db.Queues
where queue.StoreID.Equals(535)
select
new
{
Queue = queue.Queue1,
SortOrder = queue.SortOrder,
QueueName = queue.Media,
PhoneNumber = queue.PhoneNumber,
SourceID = queue.SourceID,
SourceBreakdownID = queue.SourceBreakdownID,
Active = queue.Deleted
}).OrderBy(a => a.SortOrder).ThenBy(a => a.QueueName).ToList();
var results = (from sourcebreakdowns
in
db.SourceBreakdowns
where sourcebreakdowns.SourceID == Convert.ToInt32(value) &&
!sourcebreakdowns.Deleted
orderby sourcebreakdowns.BreakdownOrder, sourcebreakdowns.BreakdownValue
select
new
{
SourceBreakdownID = sourcebreakdowns.SourceBreakdownID.ToString(),
BreakdownValue = sourcebreakdowns.BreakdownValue
}).ToList();
results.Insert(0,
new
{ SourceBreakdownID =
""
, BreakdownValue =
"Selected by user"
});
rcsourcebreakdown.Visible =
true
;
rcsourcebreakdown.DataSource = results;
rcsourcebreakdown.DataTextField =
"BreakdownValue"
;
rcsourcebreakdown.DataValueField =
"SourceBreakdownID"
;
rcsourcebreakdown.DataBind();
rcsourcebreakdown.Items.FindItemByText(
"Selected by user"
).ForeColor = Color.Red;
}
}
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 08:29 PM
Hi Pavlina,
I fixed the selection thing can u help with the "Validate thing"
I will be waiting for ur reply...
Its urgent.
Thanku in advance
I fixed the selection thing can u help with the "Validate thing"
I will be waiting for ur reply...
Its urgent.
Thanku in advance
0
Hello Nani,
I noticed that you have opened a duplicate post on the same matter. Please, refer to the other forum ticket post for additional information. To avoid duplicate posts, I suggest you continue the communication there.
Regards,
Pavlina
the Telerik team
I noticed that you have opened a duplicate post on the same matter. Please, refer to the other forum ticket post for additional information. To avoid duplicate posts, I suggest you continue the communication there.
Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now