从动态gridview中检索数据 [英] Retrieve data from dynamic gridview

查看:76
本文介绍了从动态gridview中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


i不知道这是否适合发布,但我有以下问题:


我已经在运行时构建了一个动态gridview,因为gried值(列,标题等)以来自数据库的值为条件。我使用TemplateField来做到这一点。我没有与数据库的活动连接。我将我的信息存储到数据集并将其绑定到gridview


另一件事是m gridview中的所有行都处于可编辑模式。


现在,我正在尝试从网格中检索数据以存储在数据库中并且无法正常工作。


如果我尝试这样的东西

string value =((TextBox)row.FindControl(" NAME"))。Text;

仅适用于静态控件。对于动态控件,它会给出一个null异常。


我真的觉得我走错路了。这应该更简单。


任何建议?


提前提交

hello guys,

i don''t know if this is the right tread to post but i have the following problem:

i''ve built a dynamic gridview in run time because the gried values (columns, headers, etc) are conditioned with values that come from the database. I used TemplateField''s to do that. i don''t have a active connection to the database. i store my information to a dataset and bind it to the gridview

another thing is that all rows in m gridview are in editable mode.

now, i''m trying to retrieve the data from the grid to store at database and doesn''t work.

if i try something like this
string value = ((TextBox)row.FindControl("NAME")).Text;
only works for a static control. For a dynamic control it gives a null exception.

i really feel that i''m going a wrong way. this should be more simple.

any advise?

tks in advance

推荐答案

我很困惑。 GridView的设计是动态的。使用某种数据源填充它,并使用列/行等填充自己。


然后,您可以使用列名和行索引来选择信息。
I am confused. GridView by design is dynamic. Populate with a data source of some sort and it fills itself in with columns/rows and such.

Then you can use the column name and a row index to pick out information.


问题是我不知道我的网格有多少列,因为列依赖于另一个表。在运行时,我构建数据集,然后将其绑定到网格。因此,我不能明确地引用名称或索引列:|


但是那没关系。我转到了另一个解决方案。


tks
the problem was that i don''t know how many columns my grid will have, because the columns depends of another table. at run time i build the dataset and then bind it to the grid. Because of that, i can''t refer explicitly the names or index the columns :|

But that''s ok. I moved to another solutions.

tks


嗨agamoto


女巫解决方案你搬到了?我遇到了同样的问题。


Tomas
Hi agamoto

Witch solution did you move to? I am having the same problem.

Tomas


这篇关于从动态gridview中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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