This is a migrated thread and some comments may be shown as answers.

Insert/Update issue

8 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
El
Top achievements
Rank 1
El asked on 12 Mar 2010, 02:03 PM
How do i make that when i click edit the editable fields get populated with appropriate values while when i click Insert new record buttonLink it displays the empty fields. I tried this but it does not work:

<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" HeaderText="First name" UniqueName="FirstName" Visible="true"
    <ItemTemplate> 
        <asp:Label runat="server" ID="FirstnameLabel" 
        Text='<%# Eval("FirstName") %>' /> 
    </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadTextBox TextMode="MultiLine" ID="FirstNameText" runat="server" 
        Skin="Web20" Width="300px" 
        Text='<%# Eval("FirstName") %>'  /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn>   

And also how do i populate the radcombobox controls inside EditItemTemplate with diff data e.g. diff table
<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" HeaderText="Event No." UniqueName="VidNaNast"
    <ItemTemplate> 
        <asp:Label runat="server" ID="EventLabel" 
        Text='<%# Eval("EventNumber") %>' /> 
    </ItemTemplate> 
    <EditItemTemplate> 
        <telerik:RadComboBox ID="EventCombo" runat="server" 
        Skin="Web20" Width="250px" /> 
    </EditItemTemplate> 
</telerik:GridTemplateColumn> 

Is this approach of itemtemplate and edititemtemplate ok for what i am trying to achive?

THANKS


8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 15 Mar 2010, 08:04 AM

Hi El,

If you are using automatic updates, you can use the Bind method.
<asp:TextBox  ID="TextBox2" runat="server" Text='<%# Bind("Country") %>' />  

You can use the "itemCreated"  event to populate the dropdown list in edit mode.Please try the code below.
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)   
        {   
            if ((e.Item is GridEditFormItem) && e.Item.IsInEditMode)   
            {   
                DataTable rs = global._dbconnection.GetDataTable("execute spModModulesFrontendExistingGet '" + Session.Contents["website_id"].ToString() + "'");      
                GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;   
                DropDownList dropDownList = (DropDownList)gridEditFormItem["Container"].FindControl("ddlContainer");   
                dropDownList.DataSource = rs;   
                dropDownList.DataTextField = "container_title";   
                dropDownList.DataValueField = "container_title";   
                dropDownList.DataBind();   
            }   
        } 

Thanks,
Princy


0
El
Top achievements
Rank 1
answered on 15 Mar 2010, 11:03 AM
Thanks for the reply Princy. It works but, now i don't know how to bind selected value for the radcombobox and how do i set the selected date for the rad datetimepicker control. Please tell me how to use the Bind method for these two controls. Thanks
0
El
Top achievements
Rank 1
answered on 15 Mar 2010, 08:20 PM
Also how do i set the value of the numerictextbox in the edit mode? Thanks
0
Princy
Top achievements
Rank 1
answered on 16 Mar 2010, 06:07 AM

Hi El,


In the mark-up for your RadComboBox, just add:
SelectedValue='<%#Bind("YourDataField") %>' 

Also remove the RadCombobox  DataBind() method from the ItemCreated event.

Hope this helps.

Princy
0
Princy
Top achievements
Rank 1
answered on 16 Mar 2010, 06:21 AM
Hi El,

In the mark-up for your RadComboBox, just add:
SelectedValue='<%#Bind("YourDataField") %>' 

Also remove the combo's DataBind() method from the ItemCreated event.

I hope this helps.

Princy
0
El
Top achievements
Rank 1
answered on 16 Mar 2010, 09:29 AM
SelectedValue is not present for RadComboBox as you explained. :(
0
El
Top achievements
Rank 1
answered on 16 Mar 2010, 11:59 AM
also please let me know how to set the value property of radnumeric textbox and selecteddate of raddatatimepicker. Thank you very much. It is much appreciated!
0
El
Top achievements
Rank 1
answered on 16 Mar 2010, 04:57 PM
this is what i get if i add SelectedValue to the RadComboBox tag 
The 'SelectedValue' property cannot be set declaratively.
Tags
Grid
Asked by
El
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
El
Top achievements
Rank 1
Share this question
or