用戶反饋信息textbox填充數據表,頁面使用gridview顯示反饋意見

1.用戶反饋信息textbox填充數據表

用戶通過radiobuttonlist和textbox輸入信息,後臺代碼將該信息導入數據庫中。


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public partial class WebForm9 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //數據庫連接
            SqlConnection conn = new SqlConnection("Data Source=PC-PC;Initial Catalog=TunnelMonitor;Integrated Security=True");
            string sql = "insert into UserAdvice (UserName,Grade,Advice,Time) values ('" + Session["UserName"].ToString() + "','" + RadioButtonList1.SelectedValue + "','" + TextBox1.Text + "','" + DateTime.Now.ToString() + "')";
            SqlCommand cmd = new SqlCommand(sql, conn);
            conn.Open();
            SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
        }

        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            
        }
    }
}


2.頁面使用gridview顯示反饋意見

通過gridview新建數據庫連接,連接到用戶意見數據表,用於顯示信息


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章