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. General Programming
  3. Windows API
  4. Gridview dropdownlist in c# code [modified]

Gridview dropdownlist in c# code [modified]

Scheduled Pinned Locked Moved Windows API
3 Posts 3 Posters 4 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.
  • P Offline
    P Offline
    peter bellen qsm europe com
    wrote on last edited by
    #1

    Greetings, I'm working on a web application with a dynamically creation of a gridview and within this gridview a dropdownlist (ddl) for data validation; Everything needs to be programmed dynamically in c# code. The creation of the grid + data is very easy, but on 1 field I want a ddl, so that people can only choose from certain data in this ddl. //GridView GridView2 = new GridView(); GridView2.ID = "Ellende"; GridView2.AutoGenerateColumns = false; //GridView1.DataKeyNames = new string[] { "EmployeeID" }; GridView2.AllowPaging = true; GridView2.AllowSorting = true; GridView2.PageSize = 5; BoundField bfName = new BoundField(); BoundField bf1 = new BoundField(); BoundField bf2 = new BoundField(); CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Button; cf.ShowCancelButton = true; cf.ShowSelectButton = true; bf1.DataField = "Task1"; bf1.HeaderText = "Task1"; TemplateField tf1 = new TemplateField(); tf1.HeaderText = "Task1"; DropDownList dl1 = new DropDownList(); dl1.DataSource = ObjectDataSource3; dl1.DataValueField = "Recid"; dl1.DataTextField = "Status"; dl1.SelectedValue = "Task1"; GridView2.Controls.Add(dl1); GridView2.Columns.Add(tf1); //GridView2.Columns.Add(bf1); bfName.HeaderText = "Employee Name"; bfName.DataField = "Name"; bfName.ReadOnly = true; bf2.HeaderText = "Task2"; bf2.DataField = "Task2"; bf2.ReadOnly = true; GridView2.Columns.Add(cf); GridView2.Columns.Add(bfName); //GridView2.Columns.Add(bf1); GridView2.Columns.Add(bf2); GridView2.Columns.Add(bf3); GridView2.DataSource = DT; GridView2.Visible = true; GridView2.DataBind(); The main problem is that under "Task1" I need to connect the dropdownlist somehow to the gridview when using c# code dynamically. I found out that I need a templatefield. The gridview is filled with data when using a dataset--> that easy. But the field with "Task1" needs to be connected with a ddl, from which a choice can be made. When choosing a value from the ddl --> this value needs to be stored in the datatable DT. How can I connect a DDL (with predefined data) in a gridview???? I hope somebody has an answer in c# or VB Greetings Peter Bellen -- modified at 16:17

    V T 2 Replies Last reply
    0
    • P peter bellen qsm europe com

      Greetings, I'm working on a web application with a dynamically creation of a gridview and within this gridview a dropdownlist (ddl) for data validation; Everything needs to be programmed dynamically in c# code. The creation of the grid + data is very easy, but on 1 field I want a ddl, so that people can only choose from certain data in this ddl. //GridView GridView2 = new GridView(); GridView2.ID = "Ellende"; GridView2.AutoGenerateColumns = false; //GridView1.DataKeyNames = new string[] { "EmployeeID" }; GridView2.AllowPaging = true; GridView2.AllowSorting = true; GridView2.PageSize = 5; BoundField bfName = new BoundField(); BoundField bf1 = new BoundField(); BoundField bf2 = new BoundField(); CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Button; cf.ShowCancelButton = true; cf.ShowSelectButton = true; bf1.DataField = "Task1"; bf1.HeaderText = "Task1"; TemplateField tf1 = new TemplateField(); tf1.HeaderText = "Task1"; DropDownList dl1 = new DropDownList(); dl1.DataSource = ObjectDataSource3; dl1.DataValueField = "Recid"; dl1.DataTextField = "Status"; dl1.SelectedValue = "Task1"; GridView2.Controls.Add(dl1); GridView2.Columns.Add(tf1); //GridView2.Columns.Add(bf1); bfName.HeaderText = "Employee Name"; bfName.DataField = "Name"; bfName.ReadOnly = true; bf2.HeaderText = "Task2"; bf2.DataField = "Task2"; bf2.ReadOnly = true; GridView2.Columns.Add(cf); GridView2.Columns.Add(bfName); //GridView2.Columns.Add(bf1); GridView2.Columns.Add(bf2); GridView2.Columns.Add(bf3); GridView2.DataSource = DT; GridView2.Visible = true; GridView2.DataBind(); The main problem is that under "Task1" I need to connect the dropdownlist somehow to the gridview when using c# code dynamically. I found out that I need a templatefield. The gridview is filled with data when using a dataset--> that easy. But the field with "Task1" needs to be connected with a ddl, from which a choice can be made. When choosing a value from the ddl --> this value needs to be stored in the datatable DT. How can I connect a DDL (with predefined data) in a gridview???? I hope somebody has an answer in c# or VB Greetings Peter Bellen -- modified at 16:17

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      You may like to post this in C# forum instead. C# Forum is here: http://www.codeproject.com/script/comments/forums.asp?forumid=1649[^]

      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

      1 Reply Last reply
      0
      • P peter bellen qsm europe com

        Greetings, I'm working on a web application with a dynamically creation of a gridview and within this gridview a dropdownlist (ddl) for data validation; Everything needs to be programmed dynamically in c# code. The creation of the grid + data is very easy, but on 1 field I want a ddl, so that people can only choose from certain data in this ddl. //GridView GridView2 = new GridView(); GridView2.ID = "Ellende"; GridView2.AutoGenerateColumns = false; //GridView1.DataKeyNames = new string[] { "EmployeeID" }; GridView2.AllowPaging = true; GridView2.AllowSorting = true; GridView2.PageSize = 5; BoundField bfName = new BoundField(); BoundField bf1 = new BoundField(); BoundField bf2 = new BoundField(); CommandField cf = new CommandField(); cf.ButtonType = ButtonType.Button; cf.ShowCancelButton = true; cf.ShowSelectButton = true; bf1.DataField = "Task1"; bf1.HeaderText = "Task1"; TemplateField tf1 = new TemplateField(); tf1.HeaderText = "Task1"; DropDownList dl1 = new DropDownList(); dl1.DataSource = ObjectDataSource3; dl1.DataValueField = "Recid"; dl1.DataTextField = "Status"; dl1.SelectedValue = "Task1"; GridView2.Controls.Add(dl1); GridView2.Columns.Add(tf1); //GridView2.Columns.Add(bf1); bfName.HeaderText = "Employee Name"; bfName.DataField = "Name"; bfName.ReadOnly = true; bf2.HeaderText = "Task2"; bf2.DataField = "Task2"; bf2.ReadOnly = true; GridView2.Columns.Add(cf); GridView2.Columns.Add(bfName); //GridView2.Columns.Add(bf1); GridView2.Columns.Add(bf2); GridView2.Columns.Add(bf3); GridView2.DataSource = DT; GridView2.Visible = true; GridView2.DataBind(); The main problem is that under "Task1" I need to connect the dropdownlist somehow to the gridview when using c# code dynamically. I found out that I need a templatefield. The gridview is filled with data when using a dataset--> that easy. But the field with "Task1" needs to be connected with a ddl, from which a choice can be made. When choosing a value from the ddl --> this value needs to be stored in the datatable DT. How can I connect a DDL (with predefined data) in a gridview???? I hope somebody has an answer in c# or VB Greetings Peter Bellen -- modified at 16:17

        T Offline
        T Offline
        Tauseef A
        wrote on last edited by
        #3

        gridview is not that much good in doing such a custom stuff u r doing, u can do it with some programming technique but i think that would be so complicated to get desired result and functionality which is required, u shoud better use any third party controll for that purpose .

        hello

        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