如何从像GridView的ListView中获取价值? [英] how to get value from listview like gridview?

查看:75
本文介绍了如何从像GridView的ListView中获取价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将行放置在listview 中而不是gridview
我从gridview 那里获得价值,例如

I want to put rows in listview instead of gridview
I get value from gridview like that

object[] values;
datatable cartdatatable;

protected void Addtocart_Click(object sender,EventArgs e)
values =new object[Gridview1.rows[0].Cells.Count];

for (int i=0;i<gridview1.rows[0].cells.count;i++)>
{
    cartTable.Rows.Add(values);
}


我怎么说listview.rows[0].Cells.Count
和listview.rows.add

而不是gridview ????


How can I say listview.rows[0].Cells.Count
and listview.rows.add

instead of gridview????

推荐答案



要从列表视图中读取内容,可以先选择一个特定的项目.

Hi,

To read from a listview you can select a particular item first.

private void mylistview_SelectedIndexChanged(object sender, EventArgs e)
        {
            string listviewtext = mylistview.SelectedItems[0].SubItems[1].Text;
        }



如果允许多选,则应该可以按自己的方式处理所选项目,否则可以根据需要处理列表视图中的项目.

希望对您有所帮助.



If you allow multiselect you should be able to work your way through the selected items or else you can work through allitems in the listview according to your needs.

I hope this helps.


这篇关于如何从像GridView的ListView中获取价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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