动态网格视图的FindControl [英] FindControl fo dynamic gridview

查看:67
本文介绍了动态网格视图的FindControl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经使用我的SQL 2008数据库在asp.net3.5中创建了具有动态行和列的动态gridview.

我试图不得不使用查找控制方法来查找文本框以将数据插入数据库.我没有使用编辑项目模板.

你们中的任何人都可以通过我的询问帮助我吗?

我用过
http://www.codeproject.com/KB/aspnet/create_template_columns.aspx [ ^ ]

Hi,

I have created a dynamic gridview in asp.net3.5 with dynamic rows and columns using my SQL 2008 database.

I am trying to have to use find control method to find textbox''s to insert the data into the database. I am not using edit item template.

Does anyone of you can hep me with my query?

i have used
http://www.codeproject.com/KB/aspnet/create_template_columns.aspx[^]

推荐答案

文本框TxCity =(TextBox)GrvCity.Rows [e.RowIndex] .Cells [0] .Controls [0];
TextBox txtState =(TextBox)GrvCity.Rows [e.RowIndex] .Cells [1] .Controls [0];

等等
这里的Cells [0]表示gridview的第一项
Cells [1]第二列,依此类推..

使用它可以正常工作
TextBox TxCity = (TextBox)GrvCity.Rows[e.RowIndex].Cells[0].Controls[0];
TextBox txtState= (TextBox)GrvCity.Rows[e.RowIndex].Cells[1].Controls[0];
and
so on
Here Cells[0] means first item of gridview
Cells[1] second column and so on ..

Use it it works


感谢Wasif的回答
但我没有使用gridevent args方法
iam使用showgrid()方法进行所有操作
我只想在gridview中找到控件并将其插入数据库中,而在gridview中没有按钮,我想通过按钮将记录插入到我的页面上.
Thanks Wasif for your answer
but i am not using gridevent args method
iam doing everything in a showgrid() method
i just want to find the controls in the gridview and insert them into the database i dont have an button in the gridview, i want to insert the records via the button on to my page.


这篇关于动态网格视图的FindControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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