开发者

ASP: Data binding with controls

I am implementing an online parking reservation system and I need to bind a table with 2 Controls.

for example the user selects a Reservation start date and the parking location from a RadioButtonList and then a button (Search Availability) is pushed to fetch the parking from the database according to 开发者_如何学编程the Date selected and Location.

the question is: How can I bind the (Reservation Start Date Control) with (RadioButtonList) to both search in the database? and what would be the Sql Query?

Regards.


This is pretty basic stuff so you've got a lot of work ahead of you.

On your aspx page, you will want to use a SqlDataSource and add two ControlParameters to the SelectParameters, one for the RadioButtonList, one for the TextBox/Calendar with the date. Then create a GridView control to display the results and set the DataSource of the gridview to be the SqlDataSource.

Depending on your database schema, the SQL Statement will look something like this:

SELECT * FROM [Parking] WHERE [LotID] = @LotID AND [Date] = @Date AND [Reserved] = FALSE;

However, I have done reservation systems in the past, and queries to find available spots for a particular day are rarely simple. I would suggest worrying about writing the SQL query first and then getting the web page to run the query later. If you post information about your table schema and tag it as a SQL question you'll probably have better luck.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜