1

The following is my code for row editing event.

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();
        }

after filtration using search button, I am trying editing the particular row(data) but i cannot get the gridview combobox value. it is blank. but in the full databind(first if condition) combobox value is binded.

my seach button code is

string datetime = TextBox1.Text;
            comp.DATETIME = Convert.ToDateTime(datetime);

            DataTable result = inter.searchworkday(comp);
            workingdaygrid.DataSource = result;
            workingdaygrid.DataBind();
1
  • Post your complete code. In an edit event dropdownlist bind. So from where you get the value of dropdownlist?
    – Jeet Bhatt
    Commented Jul 29, 2013 at 9:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.