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

Action Before Insert

2 Answers 13 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 14 Nov 2013, 07:15 PM
Hello Everyone!

I have an editable RadGrid, and I would like to be able to intercept the primary key value and look up a value from another table prior to the insert.  I have a working SQL Query since it will function just fine on Update (just compares primary to foreign keys already in SQL), but I cannot grab the value from the value from the textbox prior to the InsertCommand firing (compare that value to the foreign key).  I've tried capturing the textbox value on InsertCommand and InsertButton_Click.

Can anyone please advise me?

Thanks,
Mark

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 Nov 2013, 06:58 AM
Hi Mark,

Please try the following code snippet. If this doesn't help, please provide your full code snippet.

C#:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
{
    try
    {
        GridEditableItem insertitem = (GridEditableItem)e.Item;
        //Access the TextBox values for BoundColumn
        TextBox txtbound = (TextBox)insertitem["ID"].Controls[0];
        string ID = txtbound.Text;
        //Access the TextBox values for TemplateColumn
        TextBox txttemplate = (TextBox)insertitem.FindControl("TextBox1");
        string value = txttemplate.Text;
        //Query to Compare the values entered in the TextBox in InsertForm with the primany key
        //Your code to insert to DB           
    }
    catch (Exception ex)
    {
       //Exception Message
    }
}

Thanks,
Princy
0
Mark
Top achievements
Rank 1
answered on 19 Nov 2013, 10:12 PM
Thanks!
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mark
Top achievements
Rank 1
Share this question
or