Hi,
I have a RadGrid which is populated by a datasource and the columns are not autgenerated. The data returned in the RadGrid is retrieved using a parameter @Name (this corresponds to the customer name selected in a combobox) and shows corresponding quotes for this customer, So I am selecting only one customer to show multiple quotes in the resulting grid. this all works fine :) The problem is when I want to go into edit mode in order to add a new quote under this customer. I can't find a way to autofill editform fields with Default data such as AccountNumber (since the customer has been chosen we now know the account number and shouldn't need to enter this).
Is there any way to implement this easily if possible :)
Kind Regards
Ben
I have a RadGrid which is populated by a datasource and the columns are not autgenerated. The data returned in the RadGrid is retrieved using a parameter @Name (this corresponds to the customer name selected in a combobox) and shows corresponding quotes for this customer, So I am selecting only one customer to show multiple quotes in the resulting grid. this all works fine :) The problem is when I want to go into edit mode in order to add a new quote under this customer. I can't find a way to autofill editform fields with Default data such as AccountNumber (since the customer has been chosen we now know the account number and shouldn't need to enter this).
Is there any way to implement this easily if possible :)
Kind Regards
Ben
8 Answers, 1 is accepted
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Jul 2012, 07:48 PM
Hello,
Inplace edit mode
if you used editmode="editforms" then used GridEditFormItem in place of GridEditableItem.
Thanks,
Jayesh Goyani
Inplace edit mode
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.IsInEditMode && e.Item
is
GridEditableItem)
{
GridEditableItem item = e.Item
as
GridEditableItem;
(item[
"ID"
].Controls[0]
as
TextBox).Text =
"Your Text"
;
// bound column
(item.FindControl(
"TextBox1"
)
as
TextBox).Text =
"Your Text"
;
// template column
}
}
if you used editmode="editforms" then used GridEditFormItem in place of GridEditableItem.
Thanks,
Jayesh Goyani
0
Ben
Top achievements
Rank 1
answered on 18 Jul 2012, 10:49 AM
Thanks Jayesh, I had found a similar answer on the telerik forums and this is now working fine :)
Regards,
Ben
Regards,
Ben
0
Saleh
Top achievements
Rank 1
answered on 13 Apr 2016, 08:30 PM
How could I insert today's date as a default value on page load in a GridTemplateColumn?
Thanks,
0
Hello Saleh,
Try this appraoch:
Regards,
Maria Ilieva
Telerik
Try this appraoch:
<
telerik:GridTemplateColumn
AutoPostBackOnFilter
=
"true"
ReadOnly
=
"true"
UniqueName
=
"Date"
DataField
=
"Date"
>
<
ItemTemplate
>
<
telerik:RadDatePicker
runat
=
"server"
ID
=
"RadDatePicker"
SelectedDate='<%# System.DateTime.Today %>'>
</
telerik:RadDatePicker
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDatePicker
runat
=
"server"
ID
=
"RadDatePicker"
SelectedDate='<%# System.DateTime.Today %>'>
</
telerik:RadDatePicker
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Regards,
Maria Ilieva
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Saleh
Top achievements
Rank 1
answered on 20 Apr 2016, 01:20 PM
Thanks!
what about defaulting a value of a drop down list?
so when grid is in edit/view mode the value of the drop down list is selected and drop down is disabled.
And Is there a feature of hiding a specific row from a radgrid?
Thank You,
0
Hello Saleh,
You can use the same approach by simply set Enable="False" for the DropDown list in the edit item template and set specific selected item for it.
Hiding specific row form the RadGrid table is not possible int he current implementation of the control.
Regards,
Maria Ilieva
Telerik
You can use the same approach by simply set Enable="False" for the DropDown list in the edit item template and set specific selected item for it.
Hiding specific row form the RadGrid table is not possible int he current implementation of the control.
Regards,
Maria Ilieva
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Srivalli
Top achievements
Rank 1
answered on 02 Aug 2016, 02:08 PM
Hi
can you please help me to set default value in popup on radgrid add new record click event.
0
Hello,
Regards,
Maria Ilieva
Telerik by Progress
If the column is not a GridTemplateColumn
, you can specify a default value using the column's DefaultInsertValue
property, like this:
<<
telerik:GridBoundColumn
DefaultInsertValue
=
"12/21/2012"
DataType
=
"System.DateTime"
DataField
=
"Column1"
UniqueName
=
"Column1"
></
telerik:GridBoundColumn
>
Otherwise, if it is a GridTemplateColumn
, take a look at the following Telerik article :
Inserting Values Using InPlace and EditForms Modes
Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.