使用c#中的telerik从网格中选择行和索引 [英] select row and index from grid using telerik in c#

查看:89
本文介绍了使用c#中的telerik从网格中选择行和索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要帮助。我正在使用telerik web ui。我能够获取数据。现在我想创建一个选择行事件来执行我的操作。

我正在使用这个但是这不起作用。

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.

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

OnSelectedIndexChanged="RadGrid1_ItemCommand"
        Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true"



但是我收到了错误。 gridview1 selectedindexchanged没有超载匹配委托系统事件处理程序



我需要帮助尽快帮助。

谢谢


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

I need help asap.
Thank you

推荐答案

根据Tadit的解决方案,它是 RadDataGrid_SelectionChanged 事件



According to Tadit's Solution it is RadDataGrid_SelectionChanged event

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







在telerik gridview中选择行来引用这个...:)< br $>


网格 - 行选择 [ ^ ]



在RadGrid中获取行值? [ ^ ]



如何在Telerik Rad Grid中获取选定的行索引? [ ^ ]



如何访问radgrid模板列中的rowindex [ ^ ]



在客户端查找radgrid的行索引 [ ^ ]




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[^]


您已声明 OnSelectedIndexChanged =RadGrid1_ItemCommand,但您使用的是 GridCommandEventArgs

You have declared OnSelectedIndexChanged="RadGrid1_ItemCommand", but you are using GridCommandEventArgs.
protected void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)



应该看看喜欢...


That should look like...

protected void RadGrid1_ItemCommand(object source, EventArgs e)



再次如果(e.CommandName ==RowClick)不起作用,因为你不会点击任何字段有 CommandName ,而不是你要选择一行。



所以,我想你应该写另一个事件对于 SelectedIndexChanged 并且不要调用 ItemCommand


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.


这篇关于使用c#中的telerik从网格中选择行和索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆