eramgarden Posted November 11, 2005 Posted November 11, 2005 I have a dropdownlist. I want to read the data from database and populate it. I know I can do it in the code behind by populating a dataset..as explained in this link: http://www.experts-exchange.com/Web/Q_21489607.html But I like to create a class, in my code-behind call that Class and populate the ddl.. I know how to create the class, but what should be passed to it from my code-behind, what should the "return" value of the function be? If someone could give me an outline/class shell..that would be good too. Thanks Quote
Nate Bross Posted November 12, 2005 Posted November 12, 2005 I don't know if this would work, but you could make a function that uses ByRef instead of ByVal, which would allow you to directly munipulate the object in the function, and then just return a True value if it was successful, and a false if it failed. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted November 12, 2005 Administrators Posted November 12, 2005 The class, or a method of the class, could return an array or a collection which could be used for the datasource. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
eramgarden Posted November 14, 2005 Author Posted November 14, 2005 That worked, thanks. I'm following this example to add color to the background of my DropdownList ..not sure why mine doesnt work: http://www.c-sharpcorner.com/Code/2003/July/DropDownListBox.asp Public Function GetDll(ByRef retval As DataSet, ByRef ddlRptName As DropDownList) As DataSet ... Dim cmd As New SqlClient.SqlCommand("usp_rt_get_reportFiles", cnn) Dim da As New SqlDataAdapter(cmd) ... da.Fill(retval) Dim i As Integer For i = 0 To retval.Tables(0).Rows.Count - 1 ddlRptName.Items.Add(New ListItem(retval.Tables(0).Rows(i)("NewName"))) ddlRptName.Items(i).Attributes.Add("style", "color:red") Next ... Return retval .. Quote
Administrators PlausiblyDamp Posted November 14, 2005 Administrators Posted November 14, 2005 What actually happens with the above code? doesnt work isn't really giving us enough information to be able to trouble shoot the problem... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
eramgarden Posted November 14, 2005 Author Posted November 14, 2005 Sorry, It doesnt show the color. It's still "black". I also tried: ddlRptName.Items(i).Attributes.Add("style",[b] "Background-color:red"[/b] + ddlRptName.Items(i).Text) But the background is still white. Quote
eramgarden Posted November 14, 2005 Author Posted November 14, 2005 Found my answer. I have to use "<select>" and not "<asp:dropdownlist>" control. Missed that in the article. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.