well I read I can databind so I dun have to use the db more than the initial binding.
BUT I am not sure how to use this binding.
For the first item I can use a simple sql.
But the other item is written by numbers and what I want to represent is the item which this number represents-how do I do that?
This is what I currently have (excluding the using sql connection....and other lines)
The problem is my last line here.
I need to place the subject parent's name (subject parent is an id-int field) I need to search the id and insert the name isntead.
I don;t think I can add anotehr sql exectution after the "="....
So basically my question is how do I excute an sql here
Something like:
select subject_name FROM subject WHERE subject_id=subject_parent .
EDIT:I figured I misunderstood the whole thing.
What I wanna do is different than the droplist purpose and must b done differently.
Sukoshi kangaettara nanimo tokubetsu mitsukarenai node,kono mama de oiteokou ka.
Lenjaku
Member
29 Points
226 Posts
how do I populate dropbox via sql?
May 06, 2012 11:52 AM|LINK
well I read I can databind so I dun have to use the db more than the initial binding.
BUT I am not sure how to use this binding.
For the first item I can use a simple sql.
But the other item is written by numbers and what I want to represent is the item which this number represents-how do I do that?
This is what I currently have (excluding the using sql connection....and other lines)
cmd.CommandText = "SELECT subject_name,subject_parent FROM Subject"; SqlDataReader reader = cmd.ExecuteReader(); DropDownList1.DataSource = reader; DropDownList1.DataTextField = "subject_name"; DropDownList1.DataValueField = "";The problem is my last line here.
I need to place the subject parent's name (subject parent is an id-int field) I need to search the id and insert the name isntead.
I don;t think I can add anotehr sql exectution after the "="....
So basically my question is how do I excute an sql here
Something like:
select subject_name FROM subject WHERE subject_id=subject_parent .
EDIT:I figured I misunderstood the whole thing.
What I wanna do is different than the droplist purpose and must b done differently.
Richey
Contributor
3816 Points
431 Posts
Re: how do I populate dropbox via sql?
May 08, 2012 01:53 AM|LINK
Hi,
If you have solved your question you may share your answers. Then other people who comes accross the same problem can refer to it.
Thanks.
bhaskar.mule
Contributor
2280 Points
659 Posts
Re: how do I populate dropbox via sql?
May 08, 2012 02:00 AM|LINK
hi
i hope it will help you
http://csharpektroncmssql.blogspot.in/2012/04/how-to-binding-data-to-dropdown-list-in.html
Site:Rare technical solutions