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

Assign Value to Cell in Edit Mode

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 11 Jul 2011, 07:12 PM
When the user clicks the edit link on a row in the GRID I want to transfer a value one column and load that value into a different column as the default value.  The user can then edit the default or click the Update link to commit the data.

How thoughts on how to code this in the Edit Command event?

Thanks for your help,
chris

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jul 2011, 09:09 AM
Hello Chris,

I am not quite sure about your exact requirement and I suppose you want to set the default value to a TextBox which is in EditItemTemplate with a bound column TextBox value. 
aspx:
<telerik:GridTemplateColumn>
    <EditItemTemplate>
          <asp:TextBox ID="TextBox1" runat="server">
          </asp:TextBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
    {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            TextBox txt1 = item["FirstName"].Controls[0] as TextBox;
            TextBox txt = (TextBox)item.FindControl("TextBox1");//accessing bound colitem.FindControl("TextBox1");
            txt.Text = ("Value");
    }
}
Thanks,
Shinu.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or