View Full Version : AutoFilling an edit form using C#.NET and SQL

06-07-2011, 10:29 PM
Hello fellow Coders,

I am fairly new to ASP.NET, mainly C#.NET and am wondering how I can autofill a form. I know this is extremely vague, because autofilling a form can stretch from textboxes, to dropdowns.

I want help, in particular, with dropdowns, since a drop down is the first thing on my add form(which I want to auto-complete most of and allow the end user to edit...then save)

In general I want to populate a dropdown using a query, but also having one of the values from the dropdown already selected. I have no problem simply populating the dropdown.

Please assist in anyway you can, your help is greatly appreciated!
Thank you again!!


06-08-2011, 04:34 PM
Hey MyName. ,

In your codebehind (most likely inside the Page_Load), just do something like this:

MyDropDownList.SelectedValue = "My Selected Value";
For a DropDownList control, there are also SelectedIndex and SelectedItem properties you might want to look at. For a TextBox control, the property is Text. Anyway, all you have to do is look for those controls on MSDN - that will answer all such questions.


06-08-2011, 05:43 PM
Yes I am aware of those properties, however, I don't know how to use a query to make it all happen.

Here's some more detail on the question:
I want to run a query that gets an ID (one column one value)

I want to use that value in another query which will get me the value I want to select then use that value to select from a list created using a third query.

Thank you so much for your response, all of the edit pages I have seen do not do this...they just require an unfiltered column :/

Please help me if you can, I really do look forward to hearing form you. If you need anymore clarification let me know

06-08-2011, 08:37 PM
I think the best way to approach my problem is using a query string with more than 1 parameter and then use the selected... operator on the autofill function (automatically inputs data with a said ID) ..

I will post a solution to those who want to see it for future reference (beginners like myself) once I finish this edit form.

Thank you so much for those that viewed this thread :D