Filling EditForm with Default Values on a RadGrid

9 posts, 1 answers
  1. Ben
    Ben avatar
    2 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2012 Link to this post

    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
  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 17 Jul 2012 Link to this post

    Hello,

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ben
    Ben avatar
    2 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    Thanks Jayesh, I had found a similar answer on the telerik forums and this is now working fine :)

    Regards,
    Ben
  5. Saleh
    Saleh avatar
    2 posts
    Member since:
    Dec 2015

    Posted 13 Apr Link to this post

    How could I insert today's date as a default value on page load in a GridTemplateColumn?

     

    Thanks,

  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Apr Link to this post

    Hello Saleh,

    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.
  7. Saleh
    Saleh avatar
    2 posts
    Member since:
    Dec 2015

    Posted 20 Apr in reply to Maria Ilieva Link to this post

    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,

  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 25 Apr Link to this post

    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
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. Srivalli
    Srivalli avatar
    7 posts
    Member since:
    May 2016

    Posted 02 Aug in reply to Jayesh Goyani Link to this post

    Hi

    can you please help me to set default value in popup on radgrid add new record click event.

  10. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 05 Aug Link to this post

    Hello,

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017