如何将gridview seleced行显示到列表框 [英] how to display gridview seleced row to listbox

查看:76
本文介绍了如何将gridview seleced行显示到列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试如下



i我将所选行数据显示到列表框中。



为此我写的代码如下



I tried as follows

i am displaying the selected row data into listbox.

For that i written the code as follows

foreach (GridViewRow row in gvPkgcbndate.SelectedRow)
    {
        lbllist.Items.Add(row.Cells[0].Text.ToString() + " "  +            row.Cells[1].Text.ToString());

    }





如何在asp.net中使用c#。





当我运行错误时如下



foreach语句无法对变量进行操作键入System.Web.UI.WebControls.GridViewRow,因为System.Web.UI.WebControls.GridViewRow不包含GetEnumerator的公共定义。



请帮帮我什么是我犯的错误。



how can i do in asp.net using c#.


When i run error as follows

foreach statement cannot operate on variables of type System.Web.UI.WebControls.GridViewRow because System.Web.UI.WebControls.GridViewRow does not contain a public definition for GetEnumerator.

please help me what is the mistake i made.

推荐答案

GridView.SelectedRow属性返回对表示所选行的GridViewRow对象的(单个)引用。这就是为什么当你想在它上面应用循环时它会抛出错误。



尝试 -

GridView.SelectedRow Property returns a (single) reference to a GridViewRow object that represents the selected row. That's why it's throwing error when you want apply a loop on it.

Try-
lbllist.Items.Add(gvPkgcbndate.SelectedRow.Cells[0].Text.ToString() + " "  +            gvPkgcbndate.SelectedRow.Cells[1].Text.ToString());





希望,它有帮助:)



Hope, it helps :)


这篇关于如何将gridview seleced行显示到列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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