473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with dropdownlist

HI,
I have a problem with dropdownlist.i have populated dropdownlist.my problem is i have to place a particular item in ddl which is already stored in sql 2000 database.
Mar 11 '08 #1
6 765
your question is not clear

this may help if not.... ask the question clearly


Sqlcommand cmd=new sqlcommand("select items from table1",con);
Sqldatareader dr=cmd.executereader();

while(dr.read())
{
ddl.items.add(new listitems(dr[0].tostrint());
}
dr.close();
Mar 11 '08 #2
kunal pawar
297 100+
I guess, u want to show items selected which store in database.

then
SelectedVal is ur database value

Dim iIndex As Int16 = 0
Dim temp As ListItem
For Each temp In ddl.Items
If Trim(temp.Value) = Trim(SelectedVal) Then
ddl.SelectedIndex = iIndex
Exit For
End If
iIndex = iIndex + 1
Next
Mar 12 '08 #3
nev
251 100+
HI,
I have a problem with dropdownlist.i have populated dropdownlist.my problem is i have to place a particular item in ddl which is already stored in sql 2000 database.
just iterate through each record and add each item to your ddl. you can use for loop.
Mar 12 '08 #4
okie.. thanks.

i ll tell u wats happening here. i have 2 dropdownlist . one is section and another is subsection. so when i select an item in section correspondingly subsection dropdownlist will fill.. i have written the code in selected index changed.i ll save it.i am able to access that item from database place the item in section ddl but not in subsection ddl. i think this is clear .
Mar 12 '08 #5
section_selectedindexchanged( )
{

//here write the code to get the sub sections from the table
like suppose u have a table table1 and inthat colums1 contains the section and coloumn2 contains the subsection //
string query=" select coloumn2 from table1 where section1='" + section.selecteditem.tostring() +"'";


sqlcommand cmd=new sql command(query,conn);
sqldatareader dr=cmd.executereader();

while(dr.read())
{
subsections.items.add(new listitems(dr[0].tostring()));
}


}


hope this is clear

Santhu.
Mar 12 '08 #6
thanks a lot its working
regards,
Mar 12 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.