如图所示:
出勤开始与结束都是上面ddl下拉框传过来的。
4个下拉拉,数据都是从数据库来的。
如果我在把班次选择为 请选择的时候,就会报错。麻烦大家帮我修改一下代码。
protected void onduty_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
string banciID = this.DropDownList3.SelectedValue;
SqlConnection cononduty = jizhong.createConnection();
cononduty.Open();
SqlCommand cmdontudy = new SqlCommand("select * from onduty where banciID='" + banciID + "'", cononduty);
SqlDataReader sdronduty = cmdontudy.ExecuteReader();
this.onduty.DataSource = sdronduty;
this.onduty.DataTextField = "ondutyName";
this.onduty.DataValueField = "ondutyID";
this.onduty.DataBind();
sdronduty.Close();
cononduty.Close(); string banciID2 = this.DropDownList3.SelectedValue;
SqlConnection conoffduty = jizhong.createConnection();
conoffduty.Open();
SqlCommand cmdofftudy = new SqlCommand("select * from offduty where banciID='" + banciID2 + "'", conoffduty);
SqlDataReader sdroffduty = cmdofftudy.ExecuteReader();
this.offduty.DataSource = sdroffduty;
this.offduty.DataTextField = "offdutyName";
this.offduty.DataValueField = "offdutyID";
this.offduty.DataBind();
sdroffduty.Close();
cononduty.Close();
for (int i = 0; i < GridView1.Rows.Count; i++)
{
TextBox cbox1 = (TextBox)GridView1.Rows[i].FindControl("TextBox5");
TextBox cbox2 = (TextBox)GridView1.Rows[i].FindControl("TextBox6");
cbox1.Text = this.onduty.SelectedItem.Text.ToString();
cbox2.Text = this.offduty.SelectedItem.Text.ToString();
} }
解决方案 »
- 数据量大的表1、建索引;2、月表+索引+视图 请问应该采用哪种方式
- 如何使showmodaldialog生成的窗口,不被弹出窗口阻止程序阻止?
- 高手进来帮哈子忙啊!!!
- 如何在asp.net中实现给javascript传递后台查询的记录??
- dataGrid 添加删除按钮后,转换成摸板列后如何加删除对话框(内详)
- Help!!!
- asp.net性能问题,困惑。
- 谁能帮忙解决,我快崩溃了
- 自定义控件与序列化问题:我自己写了一个Web自定义控件,其中有一个属性叫ObjectName,另一个属性叫DataFields,DataFields是根据OjbectNa
- DATAGRID中CHECKBOX的判断。
- 请教一下实体查询的数据绑定问题
- 如何实现排序功能
//加一个判断
if (combox.SelectIndex != -1){
这个时候才读取
}
this.onduty.DataTextField = "ondutyName";
this.onduty.DataValueField = "ondutyID";
this.onduty.DataBind();
sdronduty.Close();
cononduty.Close();
this.onduty.ClearSelection();
this.onduty.FindbyText("请选择").Selected = true;