如何在标签或gridview中查看通用列表项 [英] how to view Generic List items in label or in gridview

查看:58
本文介绍了如何在标签或gridview中查看通用列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi friends





当从其他页面触发按钮时,如何查看我的通用列表到网页中的标签。 。或者在gridview中





hi friends


How to View my Generic List to a label in a webpage when a button is fired from another page .. or else in gridview


        string itemName;
        int count = GridView1.Rows.Count;
        List<int32> id = new List<int32>();

        foreach (GridViewRow item in GridView1.Rows)
        {
           
            itemName = item.Cells[1].Text;
            id.Add(method to get id from database);


        }
foreach (Int32 txt in id)
        {


            globalvariable+= txt.ToString();
        }





请提供一些代码



please provide some code

推荐答案

In你的c#我不知道如何编码,

但不难。



所以如果我在VB中提供它可能希望你能理解吗?



In your c# i''m not sure how to code it,
but its not difficult.

So if i provide it in VB maybe you will understand hopefully?

YOUR CODE C#

for each (GridViewRow item in GridView1.Rows)
 {

 itemName = item.Cells[1].Text;
 id.Add(method to get id from database);
 }










In VB 

For each (GridViewRow item in GridView1.Rows)
  itemName = item.Cells[1].Text
  id.Add(method to get id from database)
  'comment add the data ietem to a string
  strData = strData & itemName & vbcrlf 
  'Comment vbcrlf is same as chr(13) or enter or newline
Next
SomeLabel.Text = strData


string labelTextData = string.Empty;
int count = GridView1.Rows.Count;
List id = new List();

foreach (GridViewRow item in GridView1.Rows)
{
 labelTextData += item.Cells[1].Text + ",";
 labelTextData += (method to get Id from Database);
}
label.Text = labelTextData;





就是你想要的?为此你不需要清单。



is that what you want? for this you dont need the list.


这篇关于如何在标签或gridview中查看通用列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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