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.
17 Answers, 1 is accepted
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 05 Oct 2011, 07:15 AM
Hello,
let me know if any concern.
Thanks,
Jayesh Goyani
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<%# Eval("ID") %>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
OnSelectedIndexChanged
=
"RadComboBox1_SelectedIndexChanged"
AutoPostBack
=
"true"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<%# Eval("Name") %>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"RadComboBox2"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
></
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadComboBox RadComboBox1 = item.FindControl(
"RadComboBox1"
)
as
RadComboBox;
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
},
new
{ ID = 3, Name =
"Name3"
},
new
{ ID = 4, Name =
"Name4"
},
new
{ ID = 5, Name =
"Name5"
}
};
RadComboBox1.DataSource = data;
RadComboBox1.DataTextField =
"Name"
;
RadComboBox1.DataValueField =
"ID"
;
RadComboBox1.DataBind();
}
}
protected
void
RadComboBox1_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox RadComboBox1 = sender
as
RadComboBox;
GridEditableItem item = RadComboBox1.NamingContainer
as
GridEditableItem;
RadComboBox RadComboBox2 = item.FindControl(
"RadComboBox2"
)
as
RadComboBox;
dynamic data =
new
[] {
new
{ ID = RadComboBox1.SelectedValue.ToString(), Name =RadComboBox1.SelectedValue.ToString()}
};
RadComboBox2.DataSource = data;
RadComboBox2.DataTextField =
"Name"
;
RadComboBox2.DataValueField =
"ID"
;
RadComboBox2.DataBind();
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
},
new
{ ID = 3, Name =
"Name3"
},
new
{ ID = 4, Name =
"Name4"
},
new
{ ID = 5, Name =
"Name5"
}
};
RadGrid1.DataSource = data;
}
let me know if any concern.
Thanks,
Jayesh Goyani
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 03:41 PM
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"True"
PageSize
=
"3"
AllowSorting
=
"true"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"false"
AutoGenerateColumns
=
"False"
DataSourceID
=
"ObjectDataSource1"
ShowStatusBar
=
"true"
Width
=
"850px"
OnItemDataBound
=
"rgQueue2_ItemDataBound"
>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"TopAndBottom"
DataSourceID
=
"ObjectDataSource1"
HorizontalAlign
=
"NotSet"
EditMode
=
"InPlace"
AllowSorting
=
"false"
>
<
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"
>
</
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"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Source"
UniqueName
=
"SourceName"
HeaderStyle-Width
=
"200px"
ItemStyle-HorizontalAlign
=
"Left"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblsource"
runat
=
"server"
></
asp:Label
>
</
EditItemTemplate
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbsource"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"cmbsource_SelectedIndexChanged"
Height
=
"150px"
></
telerik:RadComboBox
>
</
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
>
<
asp:DropDownList
ID
=
"DropDownList1"
runat
=
"server"
Text='<%# Bind("Active") %>'>
<
asp:ListItem
Text
=
""
Value
=
""
></
asp:ListItem
>
<
asp:ListItem
Text
=
"Yes"
Value
=
"False"
>
</
asp:ListItem
>
<
asp:ListItem
Text
=
"No"
Value
=
"True"
></
asp:ListItem
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ValidationSettings
CommandsToValidate
=
"PerformInsert,Update"
/>
</
telerik:RadGrid
>
protected
void
rgQueue2_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;
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;
}
}
}
protected
void
cmbsource_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox rcsource = (sender
as
RadComboBox);
GridEditableItem editItem = (GridEditableItem)rcsource.NamingContainer;
RadComboBox rcsourcebreakdown = (RadComboBox)editItem.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.DataSource = results;
rcsourcebreakdown.DataTextField =
"BreakdownValue"
;
rcsourcebreakdown.DataValueField =
"SourceBreakdownID"
;
rcsourcebreakdown.DataBind();
rcsourcebreakdown.Items.FindItemByText(
"Selected by user"
).ForeColor = Color.Red;
}
}
Thanks Jayesh i have one more concern. I attached my code snipshot, my concern was when i click "Edit Button" in the row i need to set the selected value of the combobox to the "Label" text which will the past seleceted value of the combobox and should be able to change selection from der...?
Thanks in advance
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 05 Oct 2011, 05:40 PM
Hello,
please check below code snippet.
Note : we are not able to get the itemtemplate's controls value on edit mode.
for that you can use datakey (shown in above code snippet) or take any other in editTemplate(Shown in Below code snippet).
Let me know if any concern.
Thanks,
Jayesh Goyani
please check below code snippet.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
DataKeyNames
=
"ID,Name"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblID"
Text='<%# Eval("ID") %>' runat="server"></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbCountry"
runat
=
"server"
OnSelectedIndexChanged
=
"cmbCountry_SelectedIndexChanged"
AutoPostBack
=
"true"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblName"
Text='<%# Eval("Name") %>' runat="server"></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"cmbState"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadComboBox cmbCountry = item.FindControl(
"cmbCountry"
)
as
RadComboBox;
RadComboBox cmbState = item.FindControl(
"cmbState"
)
as
RadComboBox;
dynamic data =
new
[] {
new
{ CountryID = 1, CountryName =
"INDIA"
},
new
{ CountryID = 2, CountryName =
"US"
},
new
{ CountryID = 3, CountryName =
"UK"
}
};
cmbCountry.DataSource = data;
cmbCountry.DataTextField =
"CountryName"
;
cmbCountry.DataValueField =
"CountryID"
;
cmbCountry.DataBind();
if
(item.ItemIndex > -1)
{
if
(!
string
.IsNullOrEmpty(Convert.ToString(item.GetDataKeyValue(
"ID"
))))
{
cmbCountry.SelectedValue = Convert.ToString(item.GetDataKeyValue(
"ID"
));
string
strSelectedCoutry = Convert.ToString(item.GetDataKeyValue(
"ID"
));
BindCombo(cmbState, strSelectedCoutry);
}
}
}
}
protected
void
cmbCountry_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox cmbCountry = sender
as
RadComboBox;
GridEditableItem item = cmbCountry.NamingContainer
as
GridEditableItem;
RadComboBox cmbState = item.FindControl(
"cmbState"
)
as
RadComboBox;
BindCombo(cmbState,cmbCountry.SelectedValue);
}
protected
void
BindCombo(RadComboBox cmbState,
string
StrKey)
{
dynamic data =
new
[] {
new
{ StateID = 1, StateName =
"State1_"
+StrKey},
new
{ StateID = 2, StateName =
"State2_"
+StrKey},
new
{ StateID = 3, StateName =
"State3_"
+StrKey}
};
cmbState.DataSource = data;
cmbState.DataTextField =
"StateName"
;
cmbState.DataValueField =
"StateID"
;
cmbState.DataBind();
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"INDIA"
},
new
{ ID = 2, Name =
"US"
},
new
{ ID = 3, Name =
"UK"
}
};
RadGrid1.DataSource = data;
}
Note : we are not able to get the itemtemplate's controls value on edit mode.
for that you can use datakey (shown in above code snippet) or take any other in editTemplate(Shown in Below code snippet).
<
EditItemTemplate
>
<
asp:Label
ID
=
"lblNameEdit"
Text='<%# Eval("Name") %>' runat="server"></
asp:Label
>
<
asp:HiddenField
ID
=
"hfName"
runat
=
"server"
Value='<%# Eval("Name") %>' />
<
telerik:RadComboBox
ID
=
"cmbState"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
Let me know if any concern.
Thanks,
Jayesh Goyani
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 06:58 PM
Hi, Jayesh thanks for ur reply. I have a concern here regarding "Label text" i am not evaluating it in the .aspx as u can see in my code...
I am setting it through code behind so i donot have an option to say "Datakey" i guess? because its not applicable in the context.
So do i have any other option???
Thanks
I am setting it through code behind so i donot have an option to say "Datakey" i guess? because its not applicable in the context.
So do i have any other option???
Thanks
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 07:09 PM
Hi Jaysh,
I have one more problem. I have attached a capture file which explains my problem, i am trying to add a new record to grid and i have couple of requied field validators when i select a item from "Source" combobox it should fire "SelectionChanged" event but its instead firing validators and not firing selection changed event.
I think i am missing some logic here firing the events. so can u please break the logic for me..
Its urgent plz respond.
Thanks in advance
I have one more problem. I have attached a capture file which explains my problem, i am trying to add a new record to grid and i have couple of requied field validators when i select a item from "Source" combobox it should fire "SelectionChanged" event but its instead firing validators and not firing selection changed event.
I think i am missing some logic here firing the events. so can u please break the logic for me..
Its urgent plz respond.
protected
void
rgQueue_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
//Find the cell and the item to validate
GridTextBoxColumnEditor sorteditor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor(
"SortOrder"
);
TableCell cell = (TableCell)sorteditor.TextBoxControl.Parent;
RequiredFieldValidator validator =
new
RequiredFieldValidator();
sorteditor.TextBoxControl.ID =
"ID_for_validation"
;
validator.ControlToValidate = sorteditor.TextBoxControl.ID;
validator.ErrorMessage =
"\n*Required"
;
validator.ForeColor = Color.Red;
validator.Display = ValidatorDisplay.Dynamic;
cell.Controls.Add(validator);
GridTextBoxColumnEditor queueeditor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor(
"QueueName"
);
TableCell cell1 = (TableCell)queueeditor.TextBoxControl.Parent;
RequiredFieldValidator validator1 =
new
RequiredFieldValidator();
queueeditor.TextBoxControl.ID =
"ID_for_validation1"
;
validator1.ControlToValidate = queueeditor.TextBoxControl.ID;
validator1.ErrorMessage =
"\n*Required"
;
validator1.ForeColor = Color.Red;
validator1.Display = ValidatorDisplay.Dynamic;
cell1.Controls.Add(validator1);
GridTextBoxColumnEditor phoneeditor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor(
"PhoneNumber"
);
TableCell cell2 = (TableCell)phoneeditor.TextBoxControl.Parent;
RequiredFieldValidator validator2 =
new
RequiredFieldValidator();
phoneeditor.TextBoxControl.ID =
"ID_for_validation2"
;
validator2.ControlToValidate = phoneeditor.TextBoxControl.ID;
validator2.ErrorMessage =
"\n*Required"
;
validator2.ForeColor = Color.Red;
validator2.Display = ValidatorDisplay.Dynamic;
cell2.Controls.Add(validator2);
}
}
Thanks in advance
0

Nani
Top achievements
Rank 1
answered on 05 Oct 2011, 08:27 PM
HI Jayesh,
"Selected value of combobox" working awesome with ur suggestion i changed some of my coding and its working really fine...
But still need to fix the validate thing...
I am waiting for ur reply...Thanku
"Selected value of combobox" working awesome with ur suggestion i changed some of my coding and its working really fine...
But still need to fix the validate thing...
I am waiting for ur reply...Thanku
0

Jayesh Goyani
Top achievements
Rank 2
answered on 06 Oct 2011, 06:27 AM
Hello,
Please set below property.
<telerik:RadComboBox CausesValidation="false"
let me know if any concern.
Thanks,
Jayesh Goyani
Please set below property.
<telerik:RadComboBox CausesValidation="false"
let me know if any concern.
Thanks,
Jayesh Goyani
0

Nani
Top achievements
Rank 1
answered on 06 Oct 2011, 03:53 PM
Oh just as simple as that, It works cool. Thanku
One more concern is when i hit "Edit" and Press "Update" it not even going to "Radgrid1_UpdateCommand" event...
Can u tell me waht may be reason for that...??
One more concern is when i hit "Edit" and Press "Update" it not even going to "Radgrid1_UpdateCommand" event...
Can u tell me waht may be reason for that...??
protected
void
rgQueue_UpdateCommand(
object
source, GridUpdatedEventArgs e)
{
var editableItem = ((GridEditableItem)e.Item);
var sortorder = (
int
)editableItem.GetDataKeyValue(
"SortOrder"
);
//retrive entity form the Db
using
(EnabledDataContext db =
new
EnabledDataContext())
{
var queue = db.Queues.Where(n => n.StoreID == 535).FirstOrDefault();
queue.StoreID = sortorder;
if
(queue !=
null
)
{
//update entity's state
editableItem.UpdateValues(queue);
try
{
//submit chanages to Db
db.SubmitChanges();
}
catch
(System.Exception)
{
}
}
}
}
<
telerik:RadGrid
ID
=
"rgQueue"
runat
=
"server"
AllowAutomaticDeletes
=
"false"
PageSize
=
"25"
AllowSorting
=
"true"
AllowPaging
=
"false"
AutoGenerateColumns
=
"False"
DataSourceID
=
"ObjectDataSource1"
ShowStatusBar
=
"true"
Width
=
"869px"
OnItemDataBound
=
"rgQueue_ItemDataBound"
OnItemCreated
=
"rgQueue_ItemCreated"
OnItemUpdated
=
"rgQueue_UpdateCommand"
>
0

Nani
Top achievements
Rank 1
answered on 06 Oct 2011, 06:04 PM
Hi Jayesh,
I solved the event problem just placed a wrong "Event Handler"
but still had some problem updating the "Radcombobox values"
can u tell me a example of how to update the "Comboboxes"??
and one more problem is i have combobox that has items "Yes" and "No" which actual are "False" and "True" Boolean values so when i am updating its not taking the value intead its taking the selected test and giving an error "Yes or No is not a valid Boolean"v so how can i solve this problem..??
Thanku..
I solved the event problem just placed a wrong "Event Handler"
but still had some problem updating the "Radcombobox values"
can u tell me a example of how to update the "Comboboxes"??
and one more problem is i have combobox that has items "Yes" and "No" which actual are "False" and "True" Boolean values so when i am updating its not taking the value intead its taking the selected test and giving an error "Yes or No is not a valid Boolean"v so how can i solve this problem..??
Thanku..
protected
void
rgQueue_UpdateCommand(
object
source, GridCommandEventArgs e)
{
var editableItem = ((GridEditableItem)e.Item);
var Queue = (
int
)editableItem.GetDataKeyValue(
"Queue"
);
var deleted = (Boolean)editableItem.GetDataKeyValue(
"Deleted"
);
var sourceid = (
int
)editableItem.GetDataKeyValue(
"SourceID"
);
//retrive entity form the Db
using
(EnabledDataContext db =
new
EnabledDataContext())
{
var queue = db.Queues.Single(n => n.Queue1 == Queue);
if
(queue !=
null
)
{
//update entity's state
editableItem.UpdateValues(queue);
try
{
//submit chanages to Db
db.SubmitChanges();
}
catch
(System.Exception)
{
}
}
}
}
0
Hi Nani,
Please check the following code library and try to extend the functionality implemented there.
Greetings,
Pavlina
the Telerik team
Please check the following code library and try to extend the functionality implemented there.
Greetings,
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 10 Oct 2011, 05:10 PM
Thanku Pavlina I got it.
0

Velmurugan
Top achievements
Rank 1
answered on 10 Nov 2011, 07:29 AM
hi pavlina,,,
plz help me...
i am velmurugan....i am using radlistbox in rad grid.
how to get multiple selected item from radlistbox and selected should be stored in database with single ID =001
001= item1
001= item2
001= item3
001= item4
but when displying the datas in radgrid like 001= item1, item2,item3,item4 using split a string.
how to use when inserting,updating in database , radgrid.
plz help me ....urgently need for my projects
plz help me...
i am velmurugan....i am using radlistbox in rad grid.
how to get multiple selected item from radlistbox and selected should be stored in database with single ID =001
001= item1
001= item2
001= item3
001= item4
but when displying the datas in radgrid like 001= item1, item2,item3,item4 using split a string.
how to use when inserting,updating in database , radgrid.
plz help me ....urgently need for my projects
0
Hi Velmurugan,
Can you please elaborate what is the exact problem you are facing? How to get selected values or how to set them while updating/inserting in database? Do you use TemplateColumn or FormTemplate?
Additionally, I suggest that you review the help article linked below:
http://www.telerik.com/help/aspnet-ajax/grid-insert-update-delete-at-database-level.html
Best wishes,
Pavlina
the Telerik team
Can you please elaborate what is the exact problem you are facing? How to get selected values or how to set them while updating/inserting in database? Do you use TemplateColumn or FormTemplate?
Additionally, I suggest that you review the help article linked below:
http://www.telerik.com/help/aspnet-ajax/grid-insert-update-delete-at-database-level.html
Best wishes,
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

Velmurugan
Top achievements
Rank 1
answered on 23 Nov 2011, 11:23 AM
hi Pavlina
thanx for ur reply...
but i am asking, how to get selected multiple item from radlistbox in isert,update command and how to get selected values using itemdatabound when edit mode
thanx for ur reply...
but i am asking, how to get selected multiple item from radlistbox in isert,update command and how to get selected values using itemdatabound when edit mode
0

Jayesh Goyani
Top achievements
Rank 2
answered on 23 Nov 2011, 12:48 PM
Hello,
or
Thanks,
Jayesh Goyani
IList<RadListBoxItem> items = RadListBox1.SelectedItems;
foreach
(RadListBoxItem item
in
items)
{
string
strtxt = item.Text;
string
strVal = item.Value;
}
foreach
(RadListBoxItem item
in
RadListBox1.Items)
{
if
(item.Selected)
{
string
strtxt = item.Text;
string
strVal = item.Value;
}
}
Thanks,
Jayesh Goyani
0

Preeti
Top achievements
Rank 1
answered on 16 Jan 2014, 11:58 AM
Hello Jayesh,
I have a dropdown control outside of a radgrid and on the basis of selected item from dropdown I want to fill my radgrid according to the id of that item...............is there any code or link for it....whatever i search..they only contain dropdown inside radgrid....but i want opposite of it.....
I have a dropdown control outside of a radgrid and on the basis of selected item from dropdown I want to fill my radgrid according to the id of that item...............is there any code or link for it....whatever i search..they only contain dropdown inside radgrid....but i want opposite of it.....
0

Princy
Top achievements
Rank 2
answered on 17 Jan 2014, 05:10 AM
Hi Preeti,
Please try the following code snippet to fill the grid with values based on dropdownlist selection.
ASPX:
C#:
Thanks,
Princy
Please try the following code snippet to fill the grid with values based on dropdownlist selection.
ASPX:
<
asp:DropDownList
ID
=
"DropDownList1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"OrderID"
DataValueField
=
"OrderID"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"DropDownList1_SelectedIndexChanged"
>
</
asp:DropDownList
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Visible
=
"false"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString3 %>"
SelectCommand="SELECT distinct [OrderID] FROM [Orders] Order By [OrderID] DESC">
C#:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"Northwind_newConnectionString3"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(
"SELECT OrderID, ShipCity FROM Orders where OrderID='"
+ DropDownList1.SelectedValue +
"'"
, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
RadGrid1.DataSource = myDataTable;
}
protected
void
DropDownList1_SelectedIndexChanged(
object
sender, EventArgs e)
{
RadGrid1.Visible =
true
;
RadGrid1.Rebind();
}
Thanks,
Princy