如何在数据库中存储datagridviewtextbox文本 [英] how to store datagridviewtextbox text in database
本文介绍了如何在数据库中存储datagridviewtextbox文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类型为datagridviewtextbox的列的grideview,如何从此列向数据库插入数据,文本可能存在或可能不存在,在该单元格中
解决方案
< blockquote>将单元格的值移动到变量
(< span class =code-keyword> int i = 0 ; i< datagrid.rows.count; i ++)
{
string a1 = datagrid.rows [i] [ 0 ]。值跨度>;
string a2 = datagrid.rows [i] [ 1 ]。值跨度>;
保存查询;
}
试试这个.. :)
< pre lang =c#> protected void GridView1_RowDataBound( object sender,GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox myTextBox =(TextBox)(e.Row.Cells [ 1 ]。FindControl( TextBox1));
// ..insert code
}
}
i have a grideview with column of type datagridviewtextbox , how can i insert data to database from this column, text may exist or may not exist , in that cell
解决方案
Move the value for cell to variable
for(int i = 0 ;i<datagrid.rows.count ; i++) { string a1 = datagrid.rows[i][0].value; string a2 = datagrid.rows[i][1].value; Save Query; }
try this.. :)
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TextBox myTextBox = (TextBox)(e.Row.Cells[1].FindControl("TextBox1")); // ..insert code } }
这篇关于如何在数据库中存储datagridviewtextbox文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文