【问题标题】:How to store into DB RadioButtonList如何存储到 DB RadioButtonList
【发布时间】: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>

【问题讨论】:

标签: c# asp.net sql sql-server linq


【解决方案1】:

好的,我就这样解决了。

在我的课堂上:

using System.Xml.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Net.Mail;

namespace Grupo_Zulcon
{
public partial class EnvianosTuCurriculum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }




    protected void Button1_Click(object sender, EventArgs e)
    {
        Botones botones = new Botones();
        botones.SaveCVInfo2(nombre.Text, Apellidos.Text, EmpleoS.Text, DireccionPersonal.Text, RadioButtonList6.SelectedItem.Text);
    }

}
}

在 aspx.cs 代码隐藏文件中:

protected void Button1_Click(object sender, EventArgs e)
    {
        Botones botones = new Botones();
        botones.SaveCVInfo2(nombre.Text, Apellidos.Text, EmpleoS.Text, DireccionPersonal.Text, RadioButtonList6.SelectedItem.Text);
    }

对于任何可能需要它的人,谢谢。

【讨论】:

    猜你喜欢
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    • 1970-01-01
    相关资源
    最近更新 更多