updatapanel中有若干的asp:checkbox
想根据这些checkbox是否选中更新数据库的字段
并且每个checkbox要对应相应的字段,中间的方法我有点想不出来,麻烦大家帮帮忙。foreach (Control ctrl in upCkboxGl.ContentTemplateContainer.Controls)
{ string type = ctrl.GetType().ToString();
if (type == "System.Web.UI.WebControls.CheckBox")
{
if (((System.Web.UI.WebControls.CheckBox)ctrl).Checked == true)
{
}
} }
想根据这些checkbox是否选中更新数据库的字段
并且每个checkbox要对应相应的字段,中间的方法我有点想不出来,麻烦大家帮帮忙。foreach (Control ctrl in upCkboxGl.ContentTemplateContainer.Controls)
{ string type = ctrl.GetType().ToString();
if (type == "System.Web.UI.WebControls.CheckBox")
{
if (((System.Web.UI.WebControls.CheckBox)ctrl).Checked == true)
{
}
} }
解决方案 »
- 我用的是.net 2.0,怎么调用.net 3.5的方法
- Asp.net如何解决海量数据加载速度
- windows应用程序能不能生成dll文件
- 谁能告诉我一下[\s\S]*与[.\n]*的区别啊?
- 在一个页面上根据已有的坐标添加图片
- 高手们帮我解决一下啊。。好老火啊。。不知道怎么搞
- 系统从asp升级到asp.net,如何解决MD5加密的兼容问题?
- 注册信息写入数据库成了????,求助 急急
- 怎样可以读取xls文件的某个表名?如Table.xls里面的sheet1 or sheet2 or sheet3。。。具体情况请进!
- 我在web.config里面写好数据库连接,现在遇到一个问题
- 用JS实现将焦点定位到DataList中的第一条数据上
- 用正则表达式替换问题、在线等、答对给分
直接 托 控件 SQLDataSourse 进行设置 其中有一个 NONE 把他 改成ControlID 选择下 就可以在 里面自动读取值了 然后 更新 数据库字段
可以把数据库字段名存放在checkbox上然后拼接一个sql更新
为了让你看的明白一些我就贴多一点代码,也是根据选中的单选按钮来获得那一行里面某一些值。你看看:
PhilipModel pm_model = new PhilipModel();
int index;
for (int i = 0; i < this.GV.Rows.Count; i++)
{
if (((RadioButton)GV.Rows[i].Cells[1].FindControl("RadioButton1")).Checked)
{
index = GV.Rows[i].RowIndex; if (Session["UserGroup"].ToString() == "B5 PMC")
{
if (this.txtQTY.Text.Trim() == "" || this.txtPlannerlatest.Text.Trim() == "" || this.txtStausfromPMC.Text.Trim() == "" || this.txtPlnnerDate.Text.Trim() == "")
{
this.lblMessage.Text = "State:Incomplete Information";
this.lblMessage.ForeColor = Color.Red;
return;
}
else
{
pm_model.PMT_Re1 = ""; pm_model.PlannerLatest1 = txtPlannerlatest.Text.Trim();
pm_model.SoQty1 = txtQTY.Text.Trim();
pm_model.Re1 = txtRe.Text.Trim();
pm_model.ShipPed1 = ""; pm_model.StausPMC1 = txtStausfromPMC.Text.Trim();
pm_model.FactoryDate1 = "";
pm_model.PlannerDate1 = txtPlnnerDate.Text.Trim();
}
}
if (Session["UserGroup"].ToString() == "B5 PMT")
{ if (this.txtPMTRe.Text.Trim() == "" || this.txtFactorydata.Text.Trim() == "" || this.txtshipPed.Text.Trim() == "")
{
this.lblMessage.Text = "State:Incomplete Information";
this.lblMessage.ForeColor = Color.Red;
}
else
{
pm_model.PMT_Re1 = this.txtPMTRe.Text.Trim();
pm_model.PlannerLatest1 = "";
pm_model.SoQty1 = "";
pm_model.Re1 = "";
pm_model.ShipPed1 = this.txtshipPed.Text.Trim();
pm_model.StausPMC1 = "";
pm_model.FactoryDate1 = this.txtFactorydata.Text.Trim();
pm_model.PlannerDate1 = "";
}
} pm_model.SoNo1 = GV.Rows[i].Cells[2].Text.Trim();
pm_model.PoNo1 = GV.Rows[i].Cells[6].Text.Trim();
pm_model.SoLine1 = GV.Rows[i].Cells[7].Text.Trim();
pm_model.PoLine1 = GV.Rows[i].Cells[8].Text.Trim();
pm_model.VtechPN1 = GV.Rows[i].Cells[4].Text.Trim(); if (new PhilipManager().UserInputPhilipInfo(pm_model))
{
this.lblMessage.Text = "State:Success";
this.lblMessage.ForeColor = Color.Green;
}
else
{
this.lblMessage.Text = "State:Error";
this.lblMessage.ForeColor = Color.Red;
}
}
}