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

Default values for Insert Row

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 02 Sep 2011, 04:31 PM
I'm using a radgrid which looks up against a datatable.

I need to be able to configure/set what the default values are, which are assigned to the new row When the "Add a New Record" button is pressed.

Is this possible?  Currently it returns nulls.

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Sep 2011, 08:44 PM
Hello,

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
          if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
            {
if (e.Item is GridDataInsertItem) // or if(e.Item.EditIndex < 0)
                {
 
                GridEditableItem edititem = (GridEditableItem)e.Item;
              // for RadTextBox inside Template Column
                RadTextBox RadTextBox1=(RRadTextBox )edititem.FindControl("RadTextBox1");
               RadTextBox.Text = "Your Text";
 
              // for bound column
                TextBox TextBox1=(TextBox )edititem["ColumnUniqueName"].Controls[0];
             TextBox1.Text = "Your Text";
}
            }
}

let me know if any concern.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Corey
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or