Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Populate Dropdownlist in GridView EditItem [modified]

Populate Dropdownlist in GridView EditItem [modified]

Scheduled Pinned Locked Moved ASP.NET
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bardy85
    wrote on last edited by
    #1

    Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing

    protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
    {
    this.gvRegisters.EditIndex = e.NewEditIndex;
    this.SetErrorMessage("Record opened for editing", ErrorClass.Info);

        //It always returns Null
        DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany"));
        DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch"));
        DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment"));
    
        //Fills the DropdownBoxes in the EditItemTemplate
        FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment);
    }
    

    Got any Ideas???

    modified on Thursday, September 4, 2008 2:18 AM

    R D 2 Replies Last reply
    0
    • B Bardy85

      Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing

      protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
      {
      this.gvRegisters.EditIndex = e.NewEditIndex;
      this.SetErrorMessage("Record opened for editing", ErrorClass.Info);

          //It always returns Null
          DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany"));
          DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch"));
          DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment"));
      
          //Fills the DropdownBoxes in the EditItemTemplate
          FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment);
      }
      

      Got any Ideas???

      modified on Thursday, September 4, 2008 2:18 AM

      R Offline
      R Offline
      R Palanivel
      wrote on last edited by
      #2

      HI Mention the cell name or index like this DropDownList ddlList=(DropDownList)(GridView1.Rows[e.NewEditIndex].Cells[0].FindControl(""));

      R.Palanivel 10:01 4 Jan '06

      B 1 Reply Last reply
      0
      • R R Palanivel

        HI Mention the cell name or index like this DropDownList ddlList=(DropDownList)(GridView1.Rows[e.NewEditIndex].Cells[0].FindControl(""));

        R.Palanivel 10:01 4 Jan '06

        B Offline
        B Offline
        Bardy85
        wrote on last edited by
        #3

        Affraid not. I even tryed looping through each Cell, it always returns null.

        R 1 Reply Last reply
        0
        • B Bardy85

          Affraid not. I even tryed looping through each Cell, it always returns null.

          R Offline
          R Offline
          R Palanivel
          wrote on last edited by
          #4

          try to set runat="server" property else send me you gridview's HTML code.

          R.Palanivel 10:01 4 Jan '06

          B 1 Reply Last reply
          0
          • R R Palanivel

            try to set runat="server" property else send me you gridview's HTML code.

            R.Palanivel 10:01 4 Jan '06

            B Offline
            B Offline
            Bardy85
            wrote on last edited by
            #5
            R 1 Reply Last reply
            0
            • B Bardy85

              Hi, I have a DropDownList in an EditItemTemplate within the GridView. Problem is I can't find the control. In the OnDataBound there is no e.Row.RowType == DataControlRowType.EditIem like in a DataGrid. And when I try to bind the DataSet in the RowEditing Event the same thing happens. EG RowEditing

              protected void gvRegisters_RowEditing(object sender, GridViewEditEventArgs e)
              {
              this.gvRegisters.EditIndex = e.NewEditIndex;
              this.SetErrorMessage("Record opened for editing", ErrorClass.Info);

                  //It always returns Null
                  DropDownList ddlCompany = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlCompany"));
                  DropDownList ddlBranch = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlBranch"));
                  DropDownList ddlDepartment = ((DropDownList)gvRegisters.Rows\[e.NewEditIndex\].FindControl("ddlDepartment"));
              
                  //Fills the DropdownBoxes in the EditItemTemplate
                  FillLocationDropDowns(ddlCompany, ddlBranch, ddlDepartment);
              }
              

              Got any Ideas???

              modified on Thursday, September 4, 2008 2:18 AM

              D Offline
              D Offline
              dream_liner_7e7
              wrote on last edited by
              #6

              protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { if((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState ==(DataControlRowState.Edit|DataControlRowState.Alternate))) { //do your stuff } } http://blogs.ipona.com/dan/archive/2008/08/05/Three-Different-Ways-To-Find-The-Currently-Edited-Row-In.aspx[^]

              modified on Thursday, August 21, 2008 5:59 AM

              1 Reply Last reply
              0
              • B Bardy85
                R Offline
                R Offline
                R Palanivel
                wrote on last edited by
                #7

                Hi the problem is your drop downl list not loaded please check viewsouce. your c# code write. you have modify your Gridview HTML code. Thanks & Regards

                R.Palanivel 10:01 4 Jan '06

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups