GridView填充而不使用数据库 [英] GridView Population without using database

查看:87
本文介绍了GridView填充而不使用数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有3个文本框和一个提交按钮.我想在单击提交按钮时填充gridview,而无需插入和写入选择数据库.

对于第一个值,可以,但是第二个提交,则使用新的1覆盖上一个.

感谢

hello all,
i have 3 text box and a submit button . i want to populate a gridview when submit button click without inserting and writing select db.

for 1st value its ok but for second submit its override the prev with new 1.

thanks

推荐答案

IList lst=new ArrayList(); 



上面的行是为什么它代替了您的第一个提交值.

您正在重新创建整个列表,然后为其提供您提交的新用户的唯一值.

将第一个字段设为类成员,然后执行以下操作:



The above line is why it is replacing your first submit value.

You are recreating the entire list, and then giving it the only value of the new user you submitted.

Make the lst field a class member, then do this:

if( lst == null )
{
   lst = new ArrayList();
}

lst.add(user); 
GridView1.DataSource=lst; 
GridView1.DataBind();


这篇关于GridView填充而不使用数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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