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

setting editform value

3 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ugo
Top achievements
Rank 1
ugo asked on 07 Mar 2011, 05:14 PM
pls i am new in telerik radgrid,
i want to set a value to the first cell whenever someone clicks add new records on my radgrid. i want a default of  "3000" in the first column thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Mar 2011, 05:27 AM
Hello Ugo,

You could set the DefaultInsertValue property to the desired value.
aspx:
<telerik:GridBoundColumn DataField="Area"  HeaderText="Area"  DefaultInsertValue="3000" />
Thanks,
Shinu.
0
ugo
Top achievements
Rank 1
answered on 08 Mar 2011, 08:55 AM
Thanks shinu,
But is not at design time, i want it at run time.
i want when someone clicks add new record on top of the grid then a pop up insert form appears and the first column set to 3000 by default
0
Princy
Top achievements
Rank 2
answered on 08 Mar 2011, 12:54 PM
Hello Ugo,

You can try the following code snippet to achieve your scenario.
aspx:
<telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">
</telerik:GridBoundColumn>
C#:
protected void RadGrid1_ItemDataBound1(object sender, GridItemEventArgs e)
   {
     if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
       {
           GridEditFormInsertItem edititem = (GridEditFormInsertItem)e.Item;
           TextBox txt1 = (TextBox)edititem["EmployeeID"].Controls[0];
           txt1.Text = "DefaultValue";
       }
   }

Thanks,
Princy.
Tags
Grid
Asked by
ugo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ugo
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or