I am implementing this demo: http://demos.telerik.com/aspnet-ajax/input/examples/common/datagrid/defaultcs.aspx
I want a dropdown in the inline edit format. The user can select on value from the dropdown. How can I achieve this?
Also, only this dropdown column has isEdit enabled. None of the other columns are editable.
Instead of doing the above for each column, can I state somehow that all columns have isEditable=false. Only the dropdown column is editable.
Please help me.
I want a dropdown in the inline edit format. The user can select on value from the dropdown. How can I achieve this?
Also, only this dropdown column has isEdit enabled. None of the other columns are editable.
GridTextBoxColumnEditor editor = manager.GetColumnEditor("CustomerID") as GridTextBoxColumnEditor;
editor.TextBoxControl.Enabled = false;
Instead of doing the above for each column, can I state somehow that all columns have isEditable=false. Only the dropdown column is editable.
Please help me.
8 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 18 Mar 2014, 05:18 AM
Hi,
Please have a look into the sample code snippet to achieve your scenario.
ASPX:
Let me know if you have any concern.
Thanks,
Shinu.
Please have a look into the sample code snippet to achieve your scenario.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"false"
AutoGenerateEditColumn
=
"true"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
HeaderText
=
"OrderID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CustomerID"
HeaderText
=
"CustomerID"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"RadDropDownList1"
runat
=
"server"
>
<
Items
>
<
telerik:DropDownListItem
Text
=
"Item1"
/>
<
telerik:DropDownListItem
Text
=
"Item2"
/>
</
Items
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Let me know if you have any concern.
Thanks,
Shinu.
0

RB
Top achievements
Rank 1
answered on 18 Mar 2014, 03:16 PM
Can you please provide me the c# code.
0

Shinu
Top achievements
Rank 2
answered on 19 Mar 2014, 04:28 AM
Hi,
I guess that you want to make the GridBoundClumn as not editable. In order to achieve your scenario no need of any c# code. You can set the ReadOnly property of GridBoundColumn as true. The column will be displayed according to the settings of previous properties in browser mode but will not appear in the edit-form.
please elaborate your requirement if it doesn't help.
Thank,
Shinu.
I guess that you want to make the GridBoundClumn as not editable. In order to achieve your scenario no need of any c# code. You can set the ReadOnly property of GridBoundColumn as true. The column will be displayed according to the settings of previous properties in browser mode but will not appear in the edit-form.
please elaborate your requirement if it doesn't help.
Thank,
Shinu.
0

RB
Top achievements
Rank 1
answered on 19 Mar 2014, 03:43 PM
I apologise for not being precise. I want the C# code to add a dropdown in the inline edit format.
0

RB
Top achievements
Rank 1
answered on 19 Mar 2014, 10:58 PM
I am adding both GridTextBoxColumnEditor and GridDropDownColumnEditor as follows:
Can you please guide me on how can I add a dropdown list while on Inline Edit, and bind it to the datasource.
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
if (!(e.Item is GridEditFormInsertItem))
{
GridEditableItem item = e.Item as GridEditableItem;
GridEditManager manager = item.EditManager;
//Adding columns that are not editable
GridTextBoxColumnEditor editor = manager.GetColumnEditor("Description") as GridTextBoxColumnEditor;
editor.TextBoxControl.Enabled = false;
editor.TextBoxControl.BackColor = System.Drawing.Color.Gray;
editor.TextBoxControl.ForeColor = System.Drawing.Color.Black;
GridDropDownColumnEditor dropDownEditor = manager.GetColumnEditor("SourceSystemType") as GridDropDownColumnEditor;
}
}
}
0
Accepted

Shinu
Top achievements
Rank 2
answered on 20 Mar 2014, 06:59 AM
Hi,
I guess you want to replace a textbox in edit mode to DropDownList. Please take a look at the following code snippet.
C#:
Thanks,
Shinu
I guess you want to replace a textbox in edit mode to DropDownList. Please take a look at the following code snippet.
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode && !(e.Item
is
GridEditFormInsertItem))
{
GridEditableItem edit=(GridEditableItem)e.Item;
TextBox txt = (TextBox)edit[
"GridColumn"
].Controls[0];
txt.Visible =
false
;
DropDownList droplist =
new
DropDownList();
droplist.DataSource = DataSource;
droplist.DataTextField =
"Name"
;
droplist.DataValueField =
"Name"
;
droplist.DataBind();
edit[
"GridColumn"
].Controls.Add(droplist);
}
}
Thanks,
Shinu
0

Matt
Top achievements
Rank 1
answered on 24 Jun 2015, 04:26 PM
After you replace that textbox with DropDownList, how do you save the DropDownList value ?
0

Matt
Top achievements
Rank 1
answered on 24 Jun 2015, 04:37 PM
To clarify I'm using the EditMode on my RadGrid. The original textbox saves correctly but when I change the textbox to a DropDownList it no longer updates the value. I can't figure out how to assign the dropdownlist value to my original gridboundcolumn
Chris
commented on 01 Aug 2021, 04:34 AM
| edited
Top achievements
Rank 1
I know this question is 6 years old but I needed to get the value of the new dropdownlist so maybe someone else does too. This is not the complete answer to the question, but is a way to get the value of the new dropdownlist - which I assume could be assigned to the old text box.
C# Version:
myVal = (RadDropDownList)edit("GridColumn").Controls(1).SelectedText
VB version:
myVal = CType(edit("GridColumn").Controls(1), RadDropDownList).SelectedText
C# Version:
myVal = (RadDropDownList)edit("GridColumn").Controls(1).SelectedText
VB version:
myVal = CType(edit("GridColumn").Controls(1), RadDropDownList).SelectedText
Doncho
commented on 04 Aug 2021, 11:01 AM
Telerik team
Thank you for sharing this information with the community, Chris!
More on how to access embedded controls in RadGrid in EditMode and/or inside a TemplateColumn you can find in Accessing Controls in RadGrid article.