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. Assigning the SelectedValue of Dropdownlist within Gridview to a datatable field

Assigning the SelectedValue of Dropdownlist within Gridview to a datatable field

Scheduled Pinned Locked Moved ASP.NET
help
4 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.
  • S Offline
    S Offline
    sheringkapoting
    wrote on last edited by
    #1

    for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
    {
    //extract the TextBox values
    DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
    drCurrentRow = dtCurrentTable.NewRow();
    dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
    dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
    dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
    dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
    rowIndex++;
    }

    This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable

    S A 2 Replies Last reply
    0
    • S sheringkapoting

      for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
      {
      //extract the TextBox values
      DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
      drCurrentRow = dtCurrentTable.NewRow();
      dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
      dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
      dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
      dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
      rowIndex++;
      }

      This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable

      S Offline
      S Offline
      Sanjay Kunjam
      wrote on last edited by
      #2

      sheringkapoting wrote:

      But the Problem is I dont get the Selectedvalue of Dropdownlist

      Are you getting the value of Textbox of each Cells??

      Sanjay Kunjam ------------------------------------------------------------------ "Computers are useless. They can only give answers" - Pablo Picasso ------------------------------------------------------------------

      S 1 Reply Last reply
      0
      • S Sanjay Kunjam

        sheringkapoting wrote:

        But the Problem is I dont get the Selectedvalue of Dropdownlist

        Are you getting the value of Textbox of each Cells??

        Sanjay Kunjam ------------------------------------------------------------------ "Computers are useless. They can only give answers" - Pablo Picasso ------------------------------------------------------------------

        S Offline
        S Offline
        sheringkapoting
        wrote on last edited by
        #3

        Yes I Get the Values of Text Boxes, The problem lies only in Dropdown List....

        1 Reply Last reply
        0
        • S sheringkapoting

          for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
          {
          //extract the TextBox values
          DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
          drCurrentRow = dtCurrentTable.NewRow();
          dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
          dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
          dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
          dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
          rowIndex++;
          }

          This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable

          A Offline
          A Offline
          AshishChaudha
          wrote on last edited by
          #4

          change the name of ddlFrequency to ddlFrequencyFC or anything..just rename it.. see the difference.. Thanks

          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