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

Insert in radGrid with a value from a dropdown outside radGrid

3 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 26 Apr 2013, 01:25 PM
Hi,

I would like to know the best way for this scenario.

I have 3 DropDown linked together dd1, dd2 and dd3 (Outside the radGrid). The dd3 DropDown is filtering the content of my RadGrid.

The RadGrid is filled from a SQLDataSource (select storedProc). The insert, delete and update operations are also storedProc in SQL Server.

When I do an insert (add new record), I need to provide the selected value of the dd3 for the insert operation. What's the best way to do that ? Do you guys have some examples or hints or suggestions ?

Thanks

Richard

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Apr 2013, 04:29 AM
Hi,

I guess you want to access the DropDownList in the InsertCommand. Please take a look into the following code snippet.

C#:
protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    DropDownList ddl = (DropDownList)FindControl("DD3");  //accessing the DropDownList
    string value = ddl.SelectedValue; 
}

Thanks,
Princy.
0
Richard
Top achievements
Rank 1
answered on 29 Apr 2013, 01:28 PM
Hi

Thanks for the snippet.

Actually, I don't have a problematic to get the value of the DD3 DropdownList.

I just don't know how to provide the DD3 value to the SqlDataSource parameters for an insert.

Any code snippet or link for an example ?

Thanks

Richard
0
Princy
Top achievements
Rank 2
answered on 30 Apr 2013, 03:31 AM
Hi,

Please try the following code snippet.

C#:
protected void RadGrid1_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    DropDownList ddl = (DropDownList)FindControl("DD3");  //accessing the DropDownList
    string value = ddl.SelectedValue;
    //Access your DB
    string insertQuery = "INSERT INTO YourTableName (DataField) VALUES ('" + value + "')";
    //Insert into DB
}

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