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

Radgrid selected Item to Selected_item table in databas.

1 Answer 90 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sp
Top achievements
Rank 1
Sp asked on 01 Jul 2011, 04:45 PM
Hi Guru's
I am working on the RadGrid control & stuck at a point where I want to basically do the following operation:

I have a button named "Update"
then a radgrid

The requirement is as follow: The user visits the site on load of the page he will see the grid with the selected items that he had selected in his last visit... we have these values from the database,

Now when he selects the new row I have a table in the database named : "userselected" I want that his userID should be added in the list with this new itemno that he has selected..

I am using entity framework to communicate to the database.

thanks in advance
SPTECH

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 05 Jul 2011, 03:39 PM
Hi,

In order to achieve your scenario, do take the following steps:

1. Set ClientSettings.EnablePostBackOnRowClick = true for the grid.
2. Add the UserID field to the DataKeys collection of the grid's MasterTableView.
3. Attach an event handler to the ItemCommand event and implement it as follows:

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
 
    if (e.CommandName == RadGrid.SelectCommandName)
    {
 
        GridDataItem item = e.Item as GridDataItem;
        object userID = item.GetDataKeyValue("UserID");
 
        //your code for sending the userID to the database goes here.
    }
 
}

Hope it helps. Greetings,
Tsvetoslav
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Sp
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or