0
Reply

radio Button List Bind from database

Rawat

Rawat

Jun 27 2015 8:29 AM
549
helo sir i use 4 radio button in datalist and also Bind from database.application run .then i have problem i want only one option selected both 4 radiobuttonlist how to solve it . 
 
My Code is=
aspx
<table>
<%--<tr>
<td>
<asp:DropDownList ID="DropDownList_gname" runat="server">
</asp:DropDownList>
<asp:Button ID="Button1Search" runat="server" Text="Search"
onclick="Button1Search_Click" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList_gname" InitialValue="Select Category Name" ErrorMessage="*Select Category Name" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>--%>
<tr>
<td style="padding-left: 20px; padding-right: 20px;">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="1" RepeatDirection="Horizontal"
Width="100%" onitemdatabound="DataList1_ItemDataBound"
onselectedindexchanged="DataList1_SelectedIndexChanged1">
<ItemTemplate>
<table>
<tr>
<td>
<span >Question</span>
<asp:Label ID="Id" runat="server" Text='<%# Bind("ID") %>'></asp:Label>:
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Question") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<%--<p>&lt;head&gt;</p>--%>
<asp:RadioButtonList ID="RadioButtonList1"
GroupName ="aa" runat="server"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged"
ontextchanged="RadioButtonList1_TextChanged"
>
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList2" GroupName ="aa" runat="server"
onselectedindexchanged="RadioButtonList2_SelectedIndexChanged"
ontextchanged="RadioButtonList2_TextChanged"
>
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList3" GroupName ="aa" runat="server"
onselectedindexchanged="RadioButtonList3_SelectedIndexChanged"
ontextchanged="RadioButtonList3_TextChanged"
>
<asp:ListItem ></asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="RadioButtonList4" GroupName ="aa" runat="server"
onselectedindexchanged="RadioButtonList4_SelectedIndexChanged"
ontextchanged="RadioButtonList4_TextChanged"
>
</asp:RadioButtonList>
</td
</tr>
<%-- <tr>
<td>
<span>Name</span>
<asp:Label ID="Label6" runat="server" Text='<%#Bind("Student_Name") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<span>Class</span>
<asp:Label ID="Label7" runat="server" Text='<%#Bind("Class") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image1" runat="server" Width="200px" Height="200px" ImageUrl='<%# "../"+ Eval("Image") %>' />
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image2" runat="server" Width="200px" Height="200px" ImageUrl='<%#Bind("Class") %>' />
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image3" runat="server" Width="200px" Height="200px" ImageUrl='<%#Bind("Marks") %>' />
</td>
</tr>
<tr>
<td>
<asp:Image ID="Image4" runat="server" Width="200px" Height="200px" ImageUrl='<%#Bind("Percentage") %>' />
</td>
</tr>--%>
<%-- <tr>
<td style="padding-bottom: 10px; padding-top: 10px; text-align: center">
<asp:LinkButton ID="LinkButton11" runat="server" CommandArgument='<%#Bind("ID") %>'
CommandName="Delete">Delete</asp:LinkButton>
</td>
</tr>--%>
<tr>
<td>
<hr size="5px" width="100%" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
 
 
 .cs part is
 
protected void Button_save_Click(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmdEmail = new OleDbCommand("select CourseCode from AddCourse where CourseCode='" + Text_CourseCode.Text + "'", con);
OleDbDataReader drEmail = cmdEmail.ExecuteReader();
if (drEmail.HasRows)
{
while (drEmail.Read())
{
LabelError.Text = ("ERROR: Record already exists.Enter New Course Code");
// Response.Write("<script>alert('ERROR: Record already exists.Enter New Course Code.')</script>");
return;
}
}
con.Close();
con.Open();
OleDbCommand cmd = new OleDbCommand("insert into AddCourse([CourseCode],[CourseName],[MonthlyFees],[Package],[Duration],[Added_Date]) values('" + Text_CourseCode.Text + "','" + Text_CourseName.Text + "','" + Text_Fees.Text + "'," + Text_Package.Text + ",'" + Text_Duration.Text + "','" + indianTime + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Text_CourseCode.Text = "";
Text_CourseName.Text = "";
Text_Duration.Text = "";
Text_Fees.Text = "";
Text_Package.Text = "";
}
 
 
i need it urgent plese solve my problems. 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Attachment: doc1.zip