I posted this question yesterday but I do not see it in the list, and I cannot search and locate it.
I am rather new to coding in ASP.NET. However, I have been coding with Classic ASP for many years. Please be patient with me and my seemingly simple questions
I am in need of some help with Populating a Drop Down List is ASp.NET using C#. I want to be able to populate a drop down list with the ID as the value and the Text as the text shown by calling a SQL stored procedure. If possible, can you give me an example and comment what the steps are.
After much searching yesterday, I found a good example using access. But this is not what I needed. However, it did get me started with the concept.
And another question. How would I code to see the value choosen? My web forms contain mostly drop down list for items such as: state names, postal codes, area codes, dates, times, etc... Just about anything that I can use a DDL, I use it. Saves so much in the error checking.
Thank you in advance for your time.
Andrew
SQL DBATheres a few steps involved in getting data to be present on a page.
First for your application you'll need to create a DataReader object to interact with your SQLCommand which is your stored procedure. (research on how to implement a DataReader)
Then once you have data in your DataReader, you can bind it do the DDL like so:
ddl.DataSource = YourDataReaderName
ddl.DataValueField = "FieldNameofYourChoice" from your DataReader
ddl.DataTextFiled = "FiledNameofYourchoice" from your DataReader
ddl.DataBind
Basically that's it
Thank you
I was hoping to get more of a step by step instruction.
I am having alot of trouble making the database connection. I am seeing so many different types and ways of doing the same thing, that it is getting very confusing. Some inside the aspx page and some in the cs page. I would like to use the code behind cs page.
Any sites out there tell how to do that? And give good examples.
I used to use that same signature many years ago.
Thanks
Andrew
0 comments:
Post a Comment