无标题页 namespace xzbags.Admin
{
public partial class FrientsManaber : System.Web.UI.Page
{
User uu = new User();
UsersModel um = new UsersModel();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
}
//绑定
public void bind()
{
DataTable dt = uu.Friends();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = TextBox1.Text.ToString();
string address = TextBox2.Text.ToString();
DateTime time = Convert.ToDateTime(System.DateTime.Now.ToString("yy-MM-dd hh:mm:ss"));
um.WName = name;
um.Waddress = address;
um.time = time;
if (uu.AddFriends(um) > 0)
{
bind();
TextBox1.Text = "";
TextBox2.Text = "";
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox2.Text = "";
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument.ToString());
if (e.CommandName == "shan")
{
um.id = id;
if (uu.deletefriends(um, id) > 0)
{
bind();
}
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[0].Controls[0]).Text.ToString();
string address = ((TextBox)GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString();
string time = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString();
um.id = id;
um.WName = name;
um.Waddress =address;
if (uu.updatefriends(um, id) > 0)
{
GridView1.EditIndex = -1;
bind();
}
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
bind();
}
}
}
调用的类里的数据库语句。。你创建个类,自己写增删改语句吧。。
另外,团IDC网上有许多产品团购,便宜有口碑