Results 1 to 8 of 8

Thread: Populate dropdownlist...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Populate dropdownlist...

    I have a problem populating a dropdownlist with data from a dataset. Here is the code:

    PHP Code:
    string strConnection="user id=logger;password=logger;"
                
    strConnection+="database=MVS;server=4647117000N26"
                
    SqlConnection objSqlConnection = new SqlConnection(strConnection); 
                
    objSqlConnection.Open();
                
    DataSet objDataSet = new DataSet();
                
    string strOrderDetails "SELECT DISTINCT [job_name] FROM [mvs_jobs]"
                
    SqlCommand objOrdDetailCommand = new SqlCommand(strOrderDetails,objSqlConnection); 

                
    SqlDataAdapter objODAdapter = new SqlDataAdapter(objOrdDetailCommand); 

                 

                 

                
                
    objODAdapter.Fill(objDataSet);
                
    DropDownList1.DataSource objDataSet;
                
    DropDownList1.DataBind(); 
                
    objSqlConnection.Close(); 
    I am not really sure what the problem is, the dropdownbox is populated with "System.Data.DataRowView"...!?!


    anyone who can help?
    kind regards
    Henrik

  2. #2
    Member Ooogaleee's Avatar
    Join Date
    Nov 2002
    Location
    Jacksonville, FL
    Posts
    52
    ...maybe you need to set the datamember property for the drop down list...

  3. #3
    Lively Member
    Join Date
    Jan 2000
    Location
    treehouse
    Posts
    106
    Try this:

    string strConnection="user id=logger;password=logger;";
    strConnection+="database=MVS;server=4647117000N26";
    SqlConnection objSqlConnection = new SqlConnection(strConnection);
    objSqlConnection.Open();
    DataSet objDataSet = new DataSet();
    string strOrderDetails = "SELECT DISTINCT [job_name] FROM [mvs_jobs]";
    SqlCommand objOrdDetailCommand = new SqlCommand(strOrderDetails,objSqlConnection);

    SqlDataAdapter objODAdapter = new SqlDataAdapter(objOrdDetailCommand);






    objODAdapter.Fill(objDataSet);
    DropDownList1.DataSource = objDataSet;
    DropDownList1.DataTextField = "job_name"
    DropDownList1.DataBind();
    objSqlConnection.Close();

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    Thanks, it worked! Now all I have to do is to parse that variable to a new aspx page as parameter and build a crystal report based on the value... piece of cake, eh


    kind regards
    Henrik
    Sweden

  5. #5
    Lively Member
    Join Date
    Jan 2000
    Location
    treehouse
    Posts
    106

    Talking

    if you say so......(piece of cake).......(smile).

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    Now it is done, I added a reportviewer webcontrol to a new pagepage and used the parameters from the previous page as parameters to the report, then I linked that with a report I have made in Crystal Reports 9. And it WORKS!!!! (on my localhost). I am still having troubles running it in our test-server. I thnk some Crystal dll files haven't been properly registered or even distributed. Crystal Reports works in a funny way, it follows its own standards. And I had to bring out my reference bible on C# in order to understand just how to use that reportviewer control.

    Now comes the tricky part, to make the report portal dynamic with logins, profiles, possibility to add new reports to profiles etc etc etc.............the list can be as long as your imagination goes

    kind regards
    Henrik

  7. #7
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    I might add here as it's the asp.net forum that it is highly advisable to use a datareader to populate in a webform. It's faster than a dataadapter.
    I use datareader for any web work. The dataset used with a dataadapter is only of any real use in windows based application.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    Hmm, IC. Well I am still learning ASP.NET and I use the same code as I use in my C# desktop programs. Perhaps you can show a small example? I use MS SQL server.

    kind regards
    Henrik

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