简体   繁体   English

ASP.NET WebControls DataGrid获取选定的行

[英]ASP.NET WebControls DataGrid Get Selected Row

I am using a DataGrid in an ASP.NET page. 我在ASP.NET页中使用了DataGrid

When someone clicks a row with their mouse, I want to fill in data on my form using info from that DataGrid's Selected Row. 当某人用鼠标单击一行时,我想使用该DataGrid的“选定行”中的信息填写表单上的数据。

I have wired up the control's SelectedIndexChanged event, but there does not seem to be any way to access the individual rows. 我已经连接了控件的SelectedIndexChanged事件,但是似乎没有任何方法可以访问各个行。

protected void DataGridRow_Selected(object sender, EventArgs e) {
  var row = grid1. ???
}

Is there a way to do this? 有没有办法做到这一点?

I use Windows Forms mostly, so I could be missing something completely obvious to people who use WebForms on a more frequent basis. 我主要使用Windows Forms,因此对于经常使用WebForms的人来说,我可能会丢失一些完全显而易见的东西。

您可以使用像JQuery这样的Ajax来获取该网格单元格的内容并填充到表单字段中。

$("#inputfield").value($("#gridcell").html())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM