Как добавить эти переключатели?
I would like to use ASP.net, C# and SQL to display a list of tasks with checkbox to delete a task and radio buttons to set it is done or not. I maked almost everything, But how to add the radio buttons on every road i`ve add? Now there are checkbox for delete, task name and next it would be radio button IsDone and next radio button Not done. Only one could be checked of course. Please help me!
Что я уже пробовал:
.код aspx-это
<pre><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="to-do-list.aspx.cs" Inherits="ToDoList.to_do_list" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:CheckBoxList AutoPostBack="true" ID="ToDoListBoxes" runat="server" OnSelectedIndexChanged="ToDoListBoxes_OnSelectedIndexChanged"></asp:CheckBoxList> <br /><br /> <asp:TextBox runat="server" ID="ToDoName"></asp:TextBox> <asp:Button ID="CreateToDo" runat="server" Text="Add Item" OnClick="CreateToDo_OnClick" /> </div> </form> </body> </html>
и код за этим стоит
<pre>namespace ToDoList { public partial class to_do_list : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { PopulateList(); } } protected void ToDoListBoxes_OnSelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < ToDoListBoxes.Items.Count; i++) { if (ToDoListBoxes.Items[i].Selected) { ToDoSQLDataContext db = new ToDoSQLDataContext(); ToDo_Table SelectedItem = db.ToDo_Tables.Where(p => p.ToDoID == Convert.ToInt32(ToDoListBoxes.Items[i].Value)).FirstOrDefault(); db.ToDo_Tables.DeleteOnSubmit(SelectedItem); db.SubmitChanges(); PopulateList(); } } } protected void CreateToDo_OnClick(object sender, EventArgs e) { ToDoSQLDataContext db = new ToDoSQLDataContext(); ToDo_Table CurrentToDo = new ToDo_Table { dt=DateTime.Now, Name=ToDoName.Text }; db.ToDo_Tables.InsertOnSubmit(CurrentToDo); db.SubmitChanges(); PopulateList(); ToDoName.Text = string.Empty; } private void PopulateList() { ToDoSQLDataContext db = new ToDoSQLDataContext(); ToDoListBoxes.DataSource = db.ToDo_Tables; ToDoListBoxes.DataValueField = "ToDoID"; ToDoListBoxes.DataTextField = "Name"; ToDoListBoxes.DataBind(); } } }