从文本框动态绑定gridview [英] bind gridview from textboxes dynamically
问题描述
请回复我如何从表单数据动态填充gridview(不使用数据源)并且不使用会话
Please reply me how to fill a gridview from form data dynamically (without using datasource) and without using a session
我用这种方式,但是当它再次浏览时,gridview出现了旧数据.我该怎么办?
I used this way but when it browsing another time, gridview appeares with old data.What should I do?
受保护的
{
{
dt =缓存[
gridbindfromtextbox();
gridbindfromtextbox();
}
{
dt.Columns.Add(
dt.Columns.Add(
dt.Columns.Add(
dt.Columns.Add(
gridbindfromtextbox();
gridbindfromtextbox();
}
}
{
dr [
dr [
dt.Rows.Add(dr);
dt.Rows.Add(dr);
缓存[
GridView1.DataSource = dt;
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.DataBind();
}
推荐答案
您的代码难以辨认.但是,鉴于您只有一组文本框,为什么需要网格?您想输入它们并随手显示它们,而不将它们存储在任何地方?这有什么用?如果愿意,您可以将它们全部存储在viewstate中,但对我而言似乎毫无意义.
Your code is illegible. However, given that you only have one set of textboxes, why do you need a grid ? you want to enter them and show them as you go, without storing them anywhere ? What''s the use of that ? You COULD store them all in viewstate, if you wanted, but it seems pointless to me.
这篇关于从文本框动态绑定gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!