资源简介
C#开发Web留言板功能,VS版本2015,SQL server版本2014

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class background : System.Web.UI.Page
{
string strCon = “Data Source=DESKTOP-I6F115P;Initial Catalog=message_board3;Integrated Security=True“;
protected void Page_Load(object sender EventArgs e)
{
if (!IsPostBack)
{
BindGridView();
}
}
private void BindGridView()
{
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand cmd = new SqlCommand(“SELECT [username] [message][time] FROM [message]“ con);
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
this.GridView1.DataSource = ds.Tables[0];
this.GridView1.DataBind();
con.Close();
}
protected void GridView1_RowCancelingEdit(object sender GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindGridView();
}
protected void GridView1_RowEditing(object sender GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGridView();
}
protected void GridView1_RowUpdating(object sender GridViewUpdateEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string username = ((TextBox)GridView1.Rows[e.RowIndex].FindControl(“TextBox1“)).Text;
string message = ((TextBox)GridView1.Rows[e.RowIndex].FindControl(“TextBox2“)).Text;
//string time = ((TextBox)GridView1.Rows[e.RowIndex].FindControl(“TextBox3“)).Text;
//DateTime dt = Convert.ToDateTime(time);
String time = ((TextBox)GridView1.Rows[e.RowIndex].FindControl(“TextBox3“)).Text.Trim();
string strUpdate = “UPDATE message set username=‘“ + username + “‘message=‘“ + message + “‘time=‘“ + time + “‘ where username=“ + username;
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand cmd = new SqlCommand(strUpdate con);
cmd.ExecuteNonQuery();
con.Close();
GridView1.EditIndex = -1;
BindGridView();
}
protected void GridView1_RowDeleting(object sender GridViewDeleteEventArgs e)
{
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string strDel = “DELETE FROM message where username=“ + id;
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand cmd = new SqlCommand(strDel con);
cmd.ExecuteNonQuery();
con.Close();
BindGridView();
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3364 2019-05-03 11:06 留言板LJX - 完成实验三\background(1).aspx
文件 3364 2019-05-03 11:06 留言板LJX - 完成实验三\background.aspx
文件 2899 2019-05-03 11:06 留言板LJX - 完成实验三\background.aspx(1).cs
文件 2899 2019-05-03 11:06 留言板LJX - 完成实验三\background.aspx.cs
文件 2694 2019-05-03 11:07 留言板LJX - 完成实验三\CSS\st
文件 132385 2019-05-03 11:07 留言板LJX - 完成实验三\images\back.jpg
文件 30851 2019-05-03 11:07 留言板LJX - 完成实验三\images\back2.jpg
文件 383 2019-05-03 11:07 留言板LJX - 完成实验三\images\icon_pencil-edit.png
文件 534 2019-05-03 11:07 留言板LJX - 完成实验三\images\x_alt.png
文件 1456 2019-05-03 11:06 留言板LJX - 完成实验三\login(1).aspx
文件 1456 2019-05-03 11:06 留言板LJX - 完成实验三\login.aspx
文件 2135 2019-05-03 11:06 留言板LJX - 完成实验三\login.aspx(1).cs
文件 2135 2019-05-03 11:06 留言板LJX - 完成实验三\login.aspx.cs
文件 1672 2019-05-03 11:06 留言板LJX - 完成实验三\messages(1).aspx
文件 1672 2019-05-03 11:06 留言板LJX - 完成实验三\messages.aspx
文件 1808 2019-05-03 11:06 留言板LJX - 完成实验三\messages.aspx(1).cs
文件 1808 2019-05-03 11:06 留言板LJX - 完成实验三\messages.aspx.cs
文件 1551 2019-05-03 11:06 留言板LJX - 完成实验三\register(1).aspx
文件 1551 2019-05-03 11:06 留言板LJX - 完成实验三\register.aspx
文件 1273 2019-05-03 11:06 留言板LJX - 完成实验三\register.aspx(1).cs
文件 1273 2019-05-03 11:06 留言板LJX - 完成实验三\register.aspx.cs
文件 362 2019-05-03 11:06 留言板LJX - 完成实验三\Web(1).config
文件 362 2019-05-03 11:06 留言板LJX - 完成实验三\Web.config
文件 1306 2019-05-03 11:06 留言板LJX - 完成实验三\Web.Debug(1).config
文件 1306 2019-05-03 11:06 留言板LJX - 完成实验三\Web.Debug.config
文件 5242880 2019-05-03 11:08 留言板LJX - 完成实验三\实验三数据库\message_board3.mdf
文件 2097152 2019-05-03 11:07 留言板LJX - 完成实验三\实验三数据库\message_board3_log.ldf
文件 848 2019-05-03 11:06 留言板LJX - 完成实验三\数据库连接验证(1).aspx
文件 848 2019-05-03 11:06 留言板LJX - 完成实验三\数据库连接验证.aspx
文件 1263 2019-05-03 11:06 留言板LJX - 完成实验三\数据库连接验证.aspx(1).cs
............此处省略11个文件信息
- 上一篇:C#读取xm
l配置文件 - 下一篇:c#上位机数据采集源代码
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- 超市进销存管理系统 Sqlserver 数据库文
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
评论
共有 条评论