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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Display a project member in the listbox

Display a project member in the listbox

Scheduled Pinned Locked Moved ASP.NET
help
5 Posts 5 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.
  • O Offline
    O Offline
    Oga M
    wrote on last edited by
    #1

    Hello Please help me with the select statement for this.After the user select a projectname from the dropdowm.I want the listbox to display the name of all the member that were working under that project. oga m

    T N P 3 Replies Last reply
    0
    • O Oga M

      Hello Please help me with the select statement for this.After the user select a projectname from the dropdowm.I want the listbox to display the name of all the member that were working under that project. oga m

      T Offline
      T Offline
      Tirthadip
      wrote on last edited by
      #2

      withou knowing the structure of your table I am writing the SQL.... SELECT member_name FROM TableName WHERE projectname='" & mycombo.Text & "' if this is not the case please let us know your table structure...

      Tirtha "A man can ride on your back only when it is bent....."

      1 Reply Last reply
      0
      • O Oga M

        Hello Please help me with the select statement for this.After the user select a projectname from the dropdowm.I want the listbox to display the name of all the member that were working under that project. oga m

        N Offline
        N Offline
        Naveed Kamboh
        wrote on last edited by
        #3

        you need to make master + detail Well your problem needs more explination. If your data is in a single table then, first you need to bind dropdownlist with the required field you can use follwoing code or write your on code to fill the drop down list public void BindDropDownListWithQuery(string sql, DropDownList ddl) { try { mysqlCommand = new MySqlCommand(sql); dbConnect(); mysqlCommand.Connection = connection; mysqlAdapter = new MySqlDataAdapter(mysqlCommand); dataset = new DataSet(); mysqlAdapter.Fill(dataset, "Table"); ddl.DataSource = dataset.Tables[0]; ddl.DataTextField = dataset.Tables[0].Columns[0].ColumnName.ToString(); ddl.DataValueField = dataset.Tables[0].Columns[1].ColumnName.ToString(); ddl.DataBind(); } catch (Exception) { connection.Close(); connection.Dispose(); } finally { connection.Close(); connection.Dispose(); } } then you need to show Details for which you can use data grid Now its really depend if you are filling datagrid on load event with all records then you need to filter datagrid on the basiss of value selected from dropdownlist you can do that using this code if (this.RadioButtonList1.SelectedIndex == 0) { this.odsImages.FilterExpression = "fieldname=" + this.DropDownList1.SelectedValue; } else if (this.RadioButtonList1.SelectedIndex == 1) { this.odsImages.FilterExpression = "field name=" + this.DropDownList1.SelectedValue; } if you are not filling datagrid onload event of web form then you need to fill data grid with select query and you can do this using follwoing code public void BindDataGrid(string sql, GridView GV) { dbConnect(); try { mysqlCommand = new MySqlCommand(sql); mysqlCommand.Connection = connection; mysqlAdapter = new MySqlDataAdapter(mysqlCommand); dataset = new DataSet(); mysqlAdapter.Fill(dataset, "Table"); GV.DataSource = dataset; GV.DataBind(); } catch (Exception) { } finally { connection.Close(); connection.Dispose(); } } sql

        N 1 Reply Last reply
        0
        • O Oga M

          Hello Please help me with the select statement for this.After the user select a projectname from the dropdowm.I want the listbox to display the name of all the member that were working under that project. oga m

          P Offline
          P Offline
          postmaster programmingknowledge com
          wrote on last edited by
          #4

          You may want to try this link http://www.programmingknowledge.com/dataControl.aspx[^]

          1 Reply Last reply
          0
          • N Naveed Kamboh

            you need to make master + detail Well your problem needs more explination. If your data is in a single table then, first you need to bind dropdownlist with the required field you can use follwoing code or write your on code to fill the drop down list public void BindDropDownListWithQuery(string sql, DropDownList ddl) { try { mysqlCommand = new MySqlCommand(sql); dbConnect(); mysqlCommand.Connection = connection; mysqlAdapter = new MySqlDataAdapter(mysqlCommand); dataset = new DataSet(); mysqlAdapter.Fill(dataset, "Table"); ddl.DataSource = dataset.Tables[0]; ddl.DataTextField = dataset.Tables[0].Columns[0].ColumnName.ToString(); ddl.DataValueField = dataset.Tables[0].Columns[1].ColumnName.ToString(); ddl.DataBind(); } catch (Exception) { connection.Close(); connection.Dispose(); } finally { connection.Close(); connection.Dispose(); } } then you need to show Details for which you can use data grid Now its really depend if you are filling datagrid on load event with all records then you need to filter datagrid on the basiss of value selected from dropdownlist you can do that using this code if (this.RadioButtonList1.SelectedIndex == 0) { this.odsImages.FilterExpression = "fieldname=" + this.DropDownList1.SelectedValue; } else if (this.RadioButtonList1.SelectedIndex == 1) { this.odsImages.FilterExpression = "field name=" + this.DropDownList1.SelectedValue; } if you are not filling datagrid onload event of web form then you need to fill data grid with select query and you can do this using follwoing code public void BindDataGrid(string sql, GridView GV) { dbConnect(); try { mysqlCommand = new MySqlCommand(sql); mysqlCommand.Connection = connection; mysqlAdapter = new MySqlDataAdapter(mysqlCommand); dataset = new DataSet(); mysqlAdapter.Fill(dataset, "Table"); GV.DataSource = dataset; GV.DataBind(); } catch (Exception) { } finally { connection.Close(); connection.Dispose(); } } sql

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            Naveed Kamboh wrote:

            sql="select * from tbl where fieldname=" + dropdownlist.selectedvalue;

            Rather lengthy response to answer the question asked. Also, your 'solution' is far to complex for such a simple thing. Where was it mentioned in the OP that he was using a DataGrid and Radio buttons? I only see a dropdown and listbox mentioned.


            only two letters away from being an asset

            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