日期:2014-05-17 浏览次数:20537 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class information : System.Web.UI.Page
{
private string number = HttpContext.Current.Request.QueryString["num"];//从登录窗口取得登陆成功的号码
private string name;
private static int i = 0;
protected void Page_Load(object sender, EventArgs e)
{
GetData();
SqlConnection con = new SqlConnection("Server=localhost;User=sa;database=mylib;password=112233456");
SqlCommand cmd = new SqlCommand("select 昵称 from QQnum where 账号='" + number + "'", con);//取得登陆成功号码的昵称
con.Open();
name = Convert.ToString(cmd.ExecuteScalar());
con.Close();
if (i == 0)//如果第一次登录,显示**欢迎回来
{
Label1.Text = "亲爱的" + name + ",欢迎回来!";
con.Close();
}
else
Label1.Text = name+"个人资料";
}
public void GetData()//刷新页面
{
SqlConnection con = new SqlConnection("Server=localhost;User=sa;database=mylib;password=112233456");
SqlCommand cmd = new SqlCommand("Select * from QQnum where 账号='"+number+"'",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds=new DataSet();
da.Fill(ds,"QQnum");
GridView1.DataSource=ds.Tables[0].DefaultView;
this.GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)//按下更新按钮时
{
this.GridView1.EditIndex = 1;
string j;
string name = ((TextBox)(this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString();//从当前行提取出第2个个元素,重点是这个,返回的居然只是原本的值,并没修改,整个页面这个肯定错了,怎么改呢?
&