First you have to create a new web project as we discussed earlier article. How to create new project with visual studio.
Watch Video
After create the project, you have to drag and drop dropdownlist controller to form designer view.
Then click on dropdownlist controller and create the data source.
as the above picture, select SQL database and input name for data source and press OK button.
Then select how would you like to retrieve data from database. you have to select the data connection, if not available data connection, you have to create using New Connection button. After creating newly or selected with available, press next button.
Next we have to configure the select statement. There are 2 option
01. Specify custom SQL or Stored procedure
02. Specify column from table or view
01. Specify custom SQL or Stored procedure
Select Specify custom SQL or Stored procedure and press next button.In this screen you can select to options with SQL statement or Stored Procedure.
I this article I am going to explain with SQL statement . Press Query Builder for create the SQL statement.
Select the Table from Add Table and press Add button, then table will display in query builder windows.
From this query builder windows you can create your Select statement by selecting fields of the table.
and pressing Execute query button you can see the result of SQL select statement.
Pressing OK button Query builder screen close and return to previous screen, in this screen you can see the created SQL statement inside the SQL statement text box.
Pressing next you can go to next screen (Test Query) and here also again you can Test the SQL statement. And pressing OK button return to Choose data source screen.
After this process you can see the data source name with Selected data source.
There are two options
01. Select a data field to display in the DropDownlist
02. Select a data field for the value of the DropDownlist
After selecting field for these two option and press OK button. Then Data source is bind with Dropdownlist.
Final when you run the application you can see the data listed with dropdownlist.
This article is with video Watch Video.
Related articles
0 comments:
Post a Comment