need a reply of this question

  • Thread starter Thread starter Mero
  • Start date Start date
M

Mero

i use visual studio 2003 amd c#.net to make my web application

my site is about e-learning

in my site i want to set some setting in "create new lesson page" such as name, description , startdate, end date,...

i used textboxes,dropdownlist, radiobutton in the design of this page

the problem is in the code when i want to insert the selected data to a database

when i add parameters and the variable is a radio button , how can i wrote the command of the parameters in the right syntax?

for examples:

if the user have to choose a yes/no value in the setting

accept:
.yes
.no

in the query i wrote:

command.CommandText="insert into lesson(accept)values(@accept)";

command.Parameters.Add("@accept",RadioButton1. ?????????);

as i want when the user choose yes----> it will be saved "yes" in the database

so if anyoneone know how to mahe this. please reply to me
thanks
 
In your .aspx page..

<asp:RadioButtonList runat="server" ID="rbt" RepeatDirection="Horizontal">

<asp:ListItem Value="Y">Yes</asp:ListItem>

<asp:ListItem Value="N">No</asp:ListItem>

</asp:RadioButtonList>

In your .aspx.cs page..

string choice = "";

if (rbt.SelectedItem.Value == "Y")

{

choice = "Yes";

}

else

{

choice = "No";

}



and finally use this..

command.Parameters.Add("@accept", choice);
 
You will have more luck getting your questions answered in the future if you
make the subject of the post relevant to the question you have.
 
Back
Top