|
-
Jan 15th, 2003, 10:32 PM
#1
Thread Starter
Frenzied Member
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
-
Jan 16th, 2003, 10:34 AM
#2
Member
...maybe you need to set the datamember property for the drop down list...
-
Jan 16th, 2003, 12:41 PM
#3
Lively Member
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();
-
Jan 16th, 2003, 05:24 PM
#4
Thread Starter
Frenzied Member
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
-
Jan 16th, 2003, 05:32 PM
#5
Lively Member
if you say so......(piece of cake).......(smile).
-
Jan 18th, 2003, 04:12 AM
#6
Thread Starter
Frenzied Member
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
-
Jan 19th, 2003, 10:53 PM
#7
Hyperactive Member
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.
-
Jan 20th, 2003, 12:24 PM
#8
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|