CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2005
    Posts
    33

    [RESOLVED] DropDownList data rebind

    Hello,

    In my GridView I have two related columns: "Project Name" and "SubProject Name". Each column is a template column with a DropDownList. For each row, I want the SubProject ddl to show only subprojects of the Project selected in Project ddl in that specific row.

    All these ddl's are shown only in edit mode. So here is my code for RowEditing event:

    protected void grdHoursReport_RowEditing(object sender, GridViewEditEventArgs e)
    {
    grdHoursReport.EditIndex = e.NewEditIndex;
    DataBind();
    DropDownList projects =
    (DropDownList)grdHoursReport.Rows[e.NewEditIndex].Cells[5].FindControl("ddlProjectID");
    DropDownList subProjects =
    (DropDownList)grdHoursReport.Rows[e.NewEditIndex].Cells[6].FindControl("ddlSubProjectID");
    SubProjectsDataSource.FilterExpression = "ProjID = " + projects.SelectedValue;
    subProjects.DataSource = SubProjectsDataSource.Select(DataSourceSelectArguments.Empty);
    subProjects.DataTextField = "SubProjName";
    subProjects.DataValueField = "SubProjID";
    subProjects.DataBind();
    }

    So the SubProjects ddl is unbound by default, and when the user wants to edit a row, I bind the ddl to data source with appropriate filtering (by ID of the project selected in Projects ddl) - using the code above.

    Now... that doesn't work. I've put a breakpoint there, and I've noticed that the subProjects ddl is filled with all the appropriate values. But I don't see these values in the browser - the ddl stays unbound there. I understand that the problem is that all the binding is performed on server-side, and there is no postback, so I can't see the result in my browser. Is that the reason? How can I correct this?

    (Tried to put the ddl inside an AJAX update panel - didn't help...)

  2. #2
    Join Date
    Apr 2005
    Posts
    33

    Re: DropDownList data rebind

    Ok, I've solved it...

  3. #3
    Join Date
    Jun 2006
    Location
    Minnesota
    Posts
    257

    Re: DropDownList data rebind

    In that case, you might want to mark this thread as resolved by clicking the Thread Tools menu and then Mark Thread resolved.

  4. #4
    Join Date
    Apr 2005
    Posts
    33

    Re: DropDownList data rebind

    Ok, sure!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured