•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,347 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,214 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1213 | Replies: 16 | Solved
![]() |
•
•
Join Date: Feb 2008
Posts: 68
Reputation:
Rep Power: 1
Solved Threads: 2
•
•
•
•
thnks dude ,,,will go thr tht link n let u know if it wrks for me,,,,
by the way i found a the code tht i wanted finally,,,here it is ,its very simple using only sql data reader,,,here it is
well this works for me,,thnks for all ur helpDim conn = New SqlConnection("Data Source=(local);Initial Catalog=(databasename);user id=;pwd=;Trusted_Connection=yes") conn.open() Dim dr As SqlDataReader Dim cmd = New SqlCommand("select * from details", conn) dr = cmd.ExecuteReader() DropDownList1.DataSource = dr DropDownList1.DataTextField = "fname" DropDownList1.DataValueField = "srno" DropDownList1.DataBind()
dude is there ne way we can get the result by editing the line
DropDownList1.DataSource = dr
Johnny.G
Well one way is to loop through the datareader and get the values in each row and add it to dropdownlist.
This involves the following steps.
This involves the following steps.
•
•
•
•
While end of datareader
create list item instance
add fname of row(i) to listitem text
add srid of row(i) to listitem value
add listitem to dropdownlist
end while
Last edited by bala24 : Jun 26th, 2008 at 7:05 am.
Michelangelo
"The best place to find a helping hand is at the end of your own arm"
"The best place to find a helping hand is at the end of your own arm"
Do fill in the rest of the details
Dim li As ListItem
If rd.HasRows Then
Do While rd.Read
li = New ListItem
li.Text= rd.Item("fname")
li.Value = rd.Item("srid")
<dropdownlist>.Items.Add(li)
Loop
rd.close()
End If Last edited by bala24 : Jun 26th, 2008 at 7:39 am.
Michelangelo
"The best place to find a helping hand is at the end of your own arm"
"The best place to find a helping hand is at the end of your own arm"
•
•
Join Date: Feb 2008
Posts: 68
Reputation:
Rep Power: 1
Solved Threads: 2
•
•
•
•
Do fill in the rest of the details
Dim li As ListItem If rd.HasRows Then Do While rd.Read li = New ListItem li.Text= rd.Item("fname") li.Value = rd.Item("srid") <dropdownlist>.Items.Add(li) Loop rd.close() End If
mind blowing maaannnnn,,,,,solved,,,thnks,,,hav added to ur reputation,,
thnks 1ce again
Johnny.G
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: calling an aspx page in another aspx page
- Next Thread: problem regarding check box in gridview


Linear Mode