如何从asp.net 2.0 C编程的网页中的gridview控件获取文本框值# [英] how to get textbox value from a gridview control in a webpage programmed in asp.net 2.0 C#
本文介绍了如何从asp.net 2.0 C编程的网页中的gridview控件获取文本框值#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个论坛,我在论坛页面中有gridview控件中的文本框。如何在字符串中获取文本框值,以便用DB检查相同的值。我尝试过如下但没有使用
I am doing a forum where i have textbox in gridview control in forum page.How to get the textbox value in a string so as to check the same value with the DB.I have tried like below but no use
string Ques = (TextBox)GridViewFRM.Rows[i].Cells[0].FindControl("GVQuestionTextBox");
推荐答案
试试这种方式 -
Try this way -
string Ques = ((TextBox)GridViewFRM.Rows[i].FindControl("GVQuestionTextBox")).Text;
你差不多近了。试试这个。
You are almost nearer. Try this.
TextBox txt=(TextBox)GridViewFRM.Rows[i].Cells[0].FindControl("GVQuestionTextBox");
string Ques = txt.Text;//This will be desired one
在按钮点击事件中问候..
Regards..
..我尝试如下得到了我期待的结果
字符串FORID = GridViewFRM.Rows [e.RowIndex] .Cells [index] .Text; < br $>
index是gridview的列号
而不是将其视为文本框值,我对待& amp; ;直接把它作为gridview的一个值
感谢你们的所有回复
in button click event.. i tried like below and got the result what i was expecting
string FORID = GridViewFRM.Rows[e.RowIndex].Cells[index].Text;
index is the column number of the gridview
instead of treating it as textbox value, i treated & directly got it as a value from the gridview
thanks guys for all your response
这篇关于如何从asp.net 2.0 C编程的网页中的gridview控件获取文本框值#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文