Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

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
..


Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...