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

Default text in textbox

1 Answer 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryann
Top achievements
Rank 1
Ryann asked on 30 Jan 2014, 11:57 AM
Hi.
I have a grid which has edit and insert operation performed. During the insert mode for one of the column textbox i want to show a default text. How to do this when grid is in insert mode?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Jan 2014, 12:12 PM
Hi Ryann,

Please try the following code snippet to have a value for a column in insert mode:

C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.InitInsertCommandName)
 {
   e.Canceled = true;
   e.Item.OwnerTableView.InsertItem();
   GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
   TextBox txt = (TextBox)insertedItem["ColumnUniqueName"].Controls[0];
   txt.Text = "YourText";
 }
}

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