When the single option is selected, it is immediately updated to the database

Source: Internet
Author: User

Anyone who has read these two blog posts will know that after all the options are selected, the exam will be handed in again and the exam will be closed.
Http://www.cnblogs.com/insus/p/3193619.html
Http://www.cnblogs.com/insus/p/3197194.html

Now Insus. NET implements the other method, that is, when each option is selected, it is updated to the database in real time, can solve the problem of accidentally closing the web page, When you log on again, you can see that no submitted exam, the answer already saved in the database is not made in white. When the user finally handed in the paper, click the button to close the file.
When you re-open the closed exam or make corrections, you should display the choices selected by the examiner.

Okay, the problem is clear. Insus. NET uses the All-in-One method this time. Remove the user control. All functions are implemented on the web page.
The database still uses the database in the previous example. There is a program in which categorySingleChoose. csAndTest. csUnchanged.




 

In the site, create a webpage and create a Repeater control in the webpage:

 
Because it is All-in-On, we can see that the highlighted html is directly a RadioButtonList control. Now you need to bind data to the Repeater control and write the program to. aspx. cs:

 

 
Next, bind the option to the RadioButtonList control in the Repeater control. First, add an OnItemDataBound event to the Repeater control:




Before binding option data, instantiate the object SingleChoose objSingleChoose = new SingleChoose ();



After data binding is complete, we need to update the database immediately when the examinee clicks the option. Therefore, you need to implement the SelectedIndexChanged event for the RadioButtonList control, or set the property AutoPostBack to true for the RadioButtonList control. In this way, the RadioButtonList will be updated on the server every time.
Go to the Repeater control of the. aspx web page and add another event OnItemCreated:




Go to. aspx. cs to write the logic code of the above event:



One event delegates the rbl_SelectedIndexChanged event, finds the record primary key, and updates the database.



In the animation demonstration, the storage options are displayed.

rbl.SelectedValue = DataBinder.Eval(e.Item.DataItem, ).ToString();

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.