以下是我的行编辑事件代码。
protected void branchgrid_RowEditing(object sender, GridViewEditEventArgs e)
{
if (TextBox1.Text == "")
{
workingdaygrid.EditIndex = e.NewEditIndex;
bindworkingday();
GridViewRow row = workingdaygrid.Rows[e.NewEditIndex];
DropDownList dl = row.FindControl("Workingdaytype") as DropDownList;
DataTable worktype = inter.bindworkdaytype();
dl.DataSource = worktype;
dl.DataTextField = "Workingday_type";
dl.DataValueField = "Time_id";
dl.DataBind();
}
else
{
string datetime = TextBox1.Text;
comp.DATETIME = Convert.ToDateTime(datetime);
DataTable result = inter.searchworkday(comp);
workingdaygrid.DataSource = result;
workingdaygrid.DataBind();
workingdaygrid.EditIndex = e.NewEditIndex;
GridViewRow row = workingdaygrid.Rows[e.NewEditIndex];
DropDownList dl = row.FindControl("Workingdaytype") as DropDownList;
DataTable worktype = inter.bindworkdaytype();
//string datetime = TextBox1.Text;
dl.DataSource = worktype;
dl.DataTextField = "Workingday_type";
dl.DataValueField = "Time_id";
dl.DataBind();
}
使用搜索按钮过滤后,我正在尝试编辑特定的行(数据),但我无法获得 gridview 组合框的值。它是空白的。但在完整的数据绑定(第一个 if 条件)组合框中的值是绑定的。
我的搜索按钮代码是
string datetime = TextBox1.Text;
comp.DATETIME = Convert.ToDateTime(datetime);
DataTable result = inter.searchworkday(comp);
workingdaygrid.DataSource = result;
workingdaygrid.DataBind();