在不使用数据库的情况下填充网格视图 [英] fill the grid view without using database

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

问题描述

我在我的Web表单中有一个文本框和一个网格视图.因此,当我在不使用数据库的情况下单击提交"按钮时,应该在网格视图中显示的文本框中写的内容.
请帮助我..

i have a text box in my web form and a grid view. so what ever i write in the textbox that should be displayed in grid view when i click the submit button with out using the database.
plz help me..

推荐答案


检查此
Hi ,
Check this
List<string> dd = new List<string>();
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        if (ViewState["dd"] != null)
        {
            dd = (List<string>)ViewState["dd"];
        }
    }
}
protected void Button1_Click(object sender, EventArgs e)
{
    if (ViewState["dd"] != null)
    {
        dd = (List<string>)ViewState["dd"];
    }
    dd.Add(TextBox1.Text);
    GridView1.DataSource = dd.ToList();
    GridView1.DataBind();
    ViewState.Add("dd", dd);
}


另外,您可以使用数据表并填充数据表,您可以通过多种方式选择所需的内容
希望对您有帮助
最好的问候
米特瓦里(M.Mitwalli)


Also you Can use datatable and fill it there is many ways you pick what you need
Hope it helps
Best Regards
M.Mitwalli


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

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