如何将选定的griview行插入数据库 [英] how to insert selected griview rows in to database
本文介绍了如何将选定的griview行插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在数据库中插入选定的griview行
how to insert selected griview rows in to database
推荐答案
为什么不对此进行搜索?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow.aspx [
Why don''t you search on this?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow.aspx[^]
答案步骤
首先对所有网格行计数进行循环
int x = 0;
//while(x<grdrows.count)>
然后检查天气是否选择了该行
//如果所选的行为true,则
//插入数据库的代码
//else
//什么都不做
:)
steps for your answer
first make a loop for all grid rows count
int x=0;
//while(x<grdrows.count)>
then check weather the row is selected or not
// if rows selected is true then
//code for insert into databse
//else
//do nothing
:)
List<clsAppointments> objListCli = new List<clsAppointments>();
for (int x = 0; x < grdview.Rows.Count; x++)
{
CheckBox chkDoc = (CheckBox)grdview.Rows[x].FindControl("chkDoc");
if (chkDoc.Checked)
{
objListCli.Add(objApp);
}
}
if (objListCli.Count > 0)
{
// add to database
}
这篇关于如何将选定的griview行插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文