Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Friends,

I am working Asp.Net MVC 2 project.

I have RadionButton in ViewPage

Looks like:

O 1
O 2
O 3

When User Click anyone of RadioButton need to store the value in "Database".
Example: User select radiobutton "1" one need to store in database and display alter Message which value is selected. I am using EntityDatabase Framework.

Please send the Example code,I will be Thankful to you.

Thanks in Advance.
Posted
Updated 1-May-17 3:51am
v2

I don't have any code handy to send you, but it shouldn't be too hard. Anytime the state of a radiobutton changes, it will generate an event. You just need to provide a handler for the event, then generate an UPDATE query to save the new state. Whatever procedure you implement to capture the event can display a message for you using a MessageBox control.
 
Share this answer
 
Comments
Johndas 1-Oct-10 3:06am    
I Agree with you,but how to handle the Event change in MVC, i have no idea, bcoz i am new MVC pattern.. Hope someone give the idea to implementation..

Thanks very much..
My Table
Table name: Infom
Column Name: Id(PK,int), Gender(char(2)

attach database in your projecti have used the LINQ to SQL data

IN CONTROLLER
InfoDataContext idc = new InfoDataContext();
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(HomeModel hm)
{
var g = "None";
if (hm.Gender ==true)
g = "M";

else
g = "F";

Infom i = new Infom();
i.Gender = g;
idc.Infom.InsertOnSubmit(i);
idc.SubmitChanges();
return View();
}
IN MODEL
public class HomeModel
{
public bool Gender{get; set;}
}

IN VIEW
<%using (Html.BeginForm())
{ %>
<%=Html.RadioButton("Gender", true) %>Male
<%=Html.RadioButton("Gender",false) %>Female

<%} %>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900