0

I am using radio button for choosing employee type such as part-time , full-time etc.I could choose only one item according followed table structure.How can i select multiple radio button and keep these inside a table.For instance such as keeping inside an array?

+--------------+----------------+
|  EmployeeId  |  EmployeeType  |
+--------------+----------------+
|      2       |       2        |    
+--------------+----------------+
|      3       |       1        |    
+--------------+----------------+


EmployeeTypes : 
0 Part-time
1 Full-time
2 Consultant
3 Trainer
tereško
  • 58,060
  • 25
  • 98
  • 150
Goran Zooferic
  • 371
  • 8
  • 23

1 Answers1

0

In HTML, radio buttons work by posting different values to the same name - the value of the item selected.

<form action="">
<input type="radio" name="sex" value="male">Male
<input type="radio" name="sex" value="female">Female
</form>

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_radio

However, if you have a table of data, and you need to be able to edit multiple rows at the same time, there will be the need to differentiate between EmployeeType for User 2 and EmployeeType for User 3. So the radio buttons with various values might now instead post to names such as EmployeeType_2 and EmployeeType_3.

This is essentially what will happen behind the scenes when you try to do code like the following.

How can I post a list of items in MVC

At some point here you may want to actually consider using a grid control, but I'm not trying to plug Telerik or DevExpress controls. So, instead I'll mention the following that came up in my search. Perhaps other users can suggest other controls.

http://www.codeproject.com/Tips/720348/MVC-Grid-Inline-Edit

http://www.codeproject.com/Articles/165410/ASP-NET-MVC-Editable-DataTable-jQuery-DataTables-a

Community
  • 1
  • 1
Greg
  • 2,410
  • 21
  • 26