在ASP.NET中编辑,选择并显示要标记的选定行 [英] Edit, Select and show selected row to label in ASP.NET

查看:50
本文介绍了在ASP.NET中编辑,选择并显示要标记的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



Hello,

http://i.stack.imgur.com/fNHoc.png





因此,当我单击Select时,我想在Label中显示包含一行的所有数据。除了DropdownList之外,我已经设法做到了这一点。当我点击选择时,它只是空的。如上图所示。

P.S。:我没有以编程方式完成此操作。我在.aspx.cs文件中写的唯一代码。





So, when I click Select I want to show in a Label all datas that contain one row. I have managed to make this, except DropdownList. When I click "Select" it's just empty. Like in the picture above.
P.S.: I have not done this programmatically. The only code I've wrote on .aspx.cs file.

protected void GridView_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        Label1.Text = GridView1.Rows[e.NewSelectedIndex].Cells[1].Text;
        Label2.Text = GridView1.Rows[e.NewSelectedIndex].Cells[2].Text;
        Label3.Text = GridView1.Rows[e.NewSelectedIndex].Cells[3].Text;
    }

推荐答案

SelectedIndexChanging 事件中尝试以下代码。

Try below code inside the SelectedIndexChanging Event.
GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
DropDownList ddl = row.FindControl("ddlDropDownList") as DropDownList;
someLabel.Text = ddl.SelectedValue.ToString();





OP的回复



不。它不起作用,但我找到了解决方案。它是:



OP 's reply

Nope. It doesn't work, but I figured out the solution. It is:

Label drpValue = (Label)this.GridView1.Rows[e.NewSelectedIndex].Cells[1].FindControl("Label1");
Lbl1.Text = drpValue.Text;


尝试

http://www.aspsnippets.com/Articles/How-to-get-Selected -Wow-cell-value-from-GridView-in-ASPNet.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/system。 web.ui.webcontrols.gridview.selectedrow%28v = vs.110%29.aspx [ ^ ]

http://www.aspsnippets.com/Articles/Sel ection-GridView-Row-by-click-on-the-Row.aspx [ ^ ]
Try
http://www.aspsnippets.com/Articles/How-to-get-Selected-Row-cell-value-from-GridView-in-ASPNet.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow%28v=vs.110%29.aspx[^]
http://www.aspsnippets.com/Articles/Selecting-GridView-Row-by-clicking-anywhere-on-the-Row.aspx[^]


这篇关于在ASP.NET中编辑,选择并显示要标记的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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