我在datagrid控件中的每一行加入了一个Textbox控件,这个控件是用来输入一些字符,在提交时我怎么取到datagrid中每一行的textbox控件里的值,非常着急,望高手指点!!!多谢!!!
解决方案 »
- 编辑列 取值问题,求解答!!!
- 动态加减数据库表的 列
- silverlight遮罩
- 简单问题再问一遍, 因为简单, 所以还没得到答案
- 求异步socket通信解决方法!
- ajaxpro 中 send() 方法出错~ 求救!!!
- 散分啊 超级弱智的问题~~~~~~~~~~~~~~
- 怎么在DataList 的ItemDataBound 事件中给 datalist中的lable赋值呀
- DataList里面的图片显示不出来,同样的路径,放在其他地方可以正常显示。
- 服务器的回传问题?
- data怎么用程序直接导出pdf文件*******************
- 马上给分 在 asp.net中怎么样才能将一个网页放到本页中不用<!--# include file= -->和框架
{
TextBox txt = (TextBox)dgi.FindControl("TextBox的id");
if (txt != null)
string str=txt.Text.ToString();
}
{
TextBox tb = (TextBox)dgi.FindControl("yourTextBoxID");
tb.Text......
}
{
string sMainProjectID;
foreach(DataGridItem oDataGridItem in oDataGrid.Items )
//oDataGrid为你的datagride的ID
{
CheckBox oCheckBox =(CheckBox)oDataGridItem.FindControl("mycheck");
TextBox oCheckBox =(TextBox)oDataGridItem.FindControl("youtextboxid");
sMainProjectID = oCheckBox.text;}
//
}
{
TextBox txt = (TextBox)dgi.FindControl("TextBox的id");
if (txt != null)
string str;
str = txt.Text.ToString();
Response.Write("ok:" + str); }
我这样写了,还是不行,没把里面的值取到,请多指教!
{OracleConnection myConnection = new OracleConnection(ConfigurationSettings.AppSettings["human"]);
OracleDataAdapter myCommand = new OracleDataAdapter("select * from wz_dept_emp where emp_no = '1914'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "wz_dept_emp");
MyDataGrid.DataSource=ds.Tables["wz_dept_emp"].DefaultView;
MyDataGrid.DataBind();
}
private void btnquery_Click(object sender, System.EventArgs e)
{foreach(DataGridItem dgi in MyDataGrid.Items)
{TextBox txt = (TextBox)dgi.FindControl("TextBox1");
if (txt != null)
Response.Write("ok:" + txt.Text);
}}------------------------------
你的数据绑定有问题
如下:private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
OracleConnection myConnection = new OracleConnection(ConfigurationSettings.AppSettings["human"]);
OracleDataAdapter myCommand = new OracleDataAdapter("select * from wz_dept_emp where emp_no = '1914'", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "wz_dept_emp");
MyDataGrid.DataSource=ds.Tables["wz_dept_emp"].DefaultView;
MyDataGrid.DataBind();
}
}
----------------------------------------------------------------
原贴内容:
----------------------------------------------------------------
原贴内容:
----------------------------------------------------------------
非常好,按照你的方法问题已经解决了,非常非常感谢!!!再想问一下,为什么要这样?如果你的Page_Load里面没有这个判断
点击Button
页面PostBack
又重新获取数据
就把你输入的数据冲掉了
如此而已
(TextBox)dgi.FindControl("TextBox");