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

update the db with null

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 26 Nov 2013, 12:39 PM
Hi,
I want to update the db with null value if the user leaves a column value empty. How to obtain this? During edit and update i want to convert empty data to null.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2013, 12:45 PM
Hi Alyssa,

You can try the following code snippet in the UpdateCommand events of the RadGrid.

C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
 {
    if (e.Item is GridEditableItem)
    {
        GridEditableItem edit = (GridEditableItem)e.Item;
        string id =(edit["ColumnUniqueName"].Controls[0] as TextBox).Text;
        if (id == string.Empty)
        {
          id = null;
        }     
       // Code to Update id to DB
    }
 }

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