【发布时间】:2013-10-13 08:01:26
【问题描述】:
我需要知道如何将RadioButtonList 项目存储到我的 SQL 数据库中,TextBoxes 已经有了这个:
public class Botones
{
public void SaveCVInfo2(string varOne,string varTwo, string varThree)
{
using (ConexionGeneralDataContext db = new ConexionGeneralDataContext())
{
Usuario_Web columna = new Usuario_Web();
//Add new values to each fields
columna.Nombre = varOne;
columna.Apellido = varTwo;
columna.Em_solicitado = varThree;
//and the rest where the textboxes would have been
//Insert the new Customer object
db.Usuario_Web.InsertOnSubmit(columna);
//Sumbit changes to the database
db.SubmitChanges();
}
}
}
然后像这样引用它们:
protected void Button1_Click(object sender, EventArgs e)
{
Botones botones = new Botones();
botones.SaveCVInfo2(nombre.Text, Apellidos.Text, EmpleoS.Text);
}
我需要知道一种在 asp.net 中从 Radio Buttons 添加到 columna 数据的方法,同时保持与 db 的这种通信格式。
顺便说一句,我的数据库中有 varchar 用于 RadioButtonList 数据的表。
我搜索了一些教程,但只找到了一些老式的 ADO 连接示例,我在这里使用的是 Linq to SQL。
这是我在aspx 页面中使用的 RadioButtonList:
<asp:RadioButtonList ID="RadioButtonList6" RepeatColumns = "2" RepeatDirection="Vertical" RepeatLayout="Table" runat="server">
<asp:ListItem ValidationGroup="Curriculum" style="margin-right:12px; margin-top:-10px" >Si</asp:ListItem>
<asp:ListItem ValidationGroup="Curriculum" >No</asp:ListItem>
</asp:RadioButtonList>
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
谢谢,我也会在这里发布我的解决方案。
标签: c# asp.net sql sql-server linq