Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys,
I need help asap. I am using telerik web ui. I am able to fetch data . Now I want to create a select row event to perform my operation.
I am using this one but this is not working.
C#
protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)  
    { 
    if (e.CommandName == "RowClick") 
    { 
      int index = e.Item.ItemIndex; 
      GridDataItem item = (GridDataItem)RadGrid1.Items[index]; 
      //Get the values from the row uaing the columnUniqueName 
      string id = item["ColumnUniqueName"].Text; 
    } 
    }

and
C#
OnSelectedIndexChanged="RadGrid1_ItemCommand"
        Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true"

but i am getting error. no overload for gridview1 selectedindexchanged matches delegate system eventhandler

I need help asap.
Thank you
Posted
Updated 9-Jul-20 8:39am
v3

According to Tadit's Solution it is RadDataGrid_SelectionChanged event

C#
void RadDataGrid_SelectionChanged(object sender, DataGridSelectionChangedEventArgs e)
{
    var selectedItem = e.AddedItems.FirstOrDefault() as DataItemClass;
}



refer this for selection of row in telerik gridview.. :)

Grid - Row Selection[^]

Get Row values in RadGrid?[^]

How To get Selected Row Index In Telerik Rad Grid?[^]

How to access rowindex in radgrid template column[^]

Find Row Index of radgrid on client side[^]
 
Share this answer
 
v3
Comments
See my answer. He has mixed up the events. :)
Nirav Prabtani 3-Jun-14 10:06am    
i have already seen it so, i have updated my answer.
This is another event fired on Selection of Row. But OP is using OnSelectedIndexChanged, so I suggested just to correct the argument of the Event.

Anyway, let's wait for OP to reply. :)
Nirav Prabtani 3-Jun-14 10:13am    
yupp that's why i have suggested "RadDataGrid_SelectionChanged" event
Ashish Ranjan_Pirates 6-Jun-14 2:56am    
Thanx dude,
I appreciated for ur help. I solved this one.
Thanx again.
You have declared OnSelectedIndexChanged="RadGrid1_ItemCommand", but you are using GridCommandEventArgs.
C#
protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)

That should look like...
C#
protected void RadGrid1_ItemCommand(object source, EventArgs e)

Again if (e.CommandName == "RowClick") would not work, because you will not click any field having a CommandName, rather you would select a Row.

So, I guess you should write another Event for SelectedIndexChanged and don't call the ItemCommand.
 
Share this answer
 
Comments
Ashish Ranjan_Pirates 6-Jun-14 2:58am    
Thanx for help. But i had another expectation. BDW i solved my Problem.
Thanx again.
RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
{
GetDataItem item = (GridDataItem)RadGrid1.SelectedItems[0];
string something = item["boundcolumn1"].Text;
string anotherthing = item["boundcolumn2"].Text;
}

// you can retrieve any of the data from the bound columns as indicated in
// the item labeled boundcolumn which is not the column name but the name of the
// databound.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900