📄 updatemsg.aspx.cs
字号:
StringWriter writer1 = new StringWriter(CultureInfo.InvariantCulture);
HtmlTextWriter writer2 = new HtmlTextWriter(writer1);
control.RenderControl(writer2);
writer2.Flush();
writer2.Close();
return writer1.ToString();
}
private void xmlBind(string sortid, string sType)
{
string mystr = "";
string sql = "";
if (sType == "1")
{
sql = "select provinceID as id,province as sname from province where father = " + sortid;
}
else
{
sql = "select cityID as id,city as sname from city where father = " + sortid;
//string sValue = this.Province.SelectedValue;
////第一个下拉框有值才开始绑定第二个下拉框
//if (sValue != "")
//{
//默认显示分类号为1的所有子类
// string cmd = "select cityID,city from city where father = " + sortid;
// DataTable tab = this.Get_Dt(cmd);
// //绑牢控件
// this.City.DataSource = tab;
// this.City.DataSource = tab;
// this.City.DataValueField = "cityID";
// this.City.DataTextField = "city";
// this.City.DataBind();
////}
}
DataTable mytab = this.Get_Dt(sql);
//将取到的值形成: ID|名称,ID|名称...这样的形式
if (mytab.Rows.Count != 0)
{
for (int i = 0; i < mytab.Rows.Count; i++)
{
mystr += "," + mytab.Rows[i]["id"].ToString() + "|" + mytab.Rows[i]["sname"].ToString();
}
mystr = mystr.Substring(1);
}
//输出页面
this.Response.Write(mystr);
this.Response.End();
}
private DataTable Get_Dt(string sql)
{
//数据库连接串,本数据库为Sql数据库,当前在本目录的根目录下
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
conn.Open();
SqlDataAdapter myAdp = new SqlDataAdapter(sql, conn);
DataTable myDt = new DataTable();
//填充数据
myAdp.Fill(myDt);
//返回数据集
conn.Close();
return (myDt);
}
/// <summary>
/// 绑定第一个下拉框
/// </summary>
private void DownBind1()
{
//显示所有的主分类
string sql = "select CountryID,CountryName from Country ";
DataTable mytab = this.Get_Dt(sql);
//绑定第一个下拉框
this.Country.DataSource = mytab;
this.Country.DataValueField = "CountryID";
this.Country.DataTextField = "CountryName";
this.Country.DataBind();
//添加一个"请选择"行
// this.Country.Items.Insert(0, new ListItem("请选择分类", ""));
//为此下拉框添加一个默认选择项,选中第2个选项
if (this.Country.Items.Count > 1)
{
this.Country.SelectedIndex = 0;
}
//为此下拉框添加选择事件,第一个参数是自己
//第二个参数为要填充的下拉框的名称
//第三个参数为求取类型
this.Country.Attributes.Add("onchange", "XmlPost(this,'" + this.Province.ClientID + "','1') ");
}
/// <summary>
/// 绑定第二个下拉框
/// </summary>
private void DownBind2()
{
string sValue = this.Country.SelectedValue;
//为第二个下拉框添加事件
this.Province.Attributes.Add("onchange", "XmlPost(this,'" + this.City.ClientID + "','2') ");
//第一个下拉框有值才开始绑定第二个下拉框
if (sValue != "")
{
//默认显示分类号为1的所有子类
string sql = "select provinceID,province from province where father = " + sValue;
DataTable mytab = this.Get_Dt(sql);
//绑牢控件
this.Province.DataSource = mytab;
this.Province.DataValueField = "provinceID";
this.Province.DataTextField = "province";
this.Province.DataBind();
}
//添加一个空的首行
// this.Province.Items.Insert(0, new ListItem("请选择省份", ""));
//如果有选项,则选中它
if (this.Province.Items.Count > 1)
{
this.Province.SelectedIndex = 0;
}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
public string picpath(object source)
{
String Temp = source.ToString();
Temp = Temp.Substring(2, Temp.Length - 2);
return Temp;
}
public void Databind()
{
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string cmd = "select * from UserInfo where UserID='" + Session["UserID"].ToString() + "'"; //设置SQL命令
// string cmd = " select * from UserInfo where UserID='04157008'";
conn.Open();
SqlCommand myCommand = new SqlCommand(cmd, conn);
SqlDataReader jie = myCommand.ExecuteReader();
//保存用户 资料
// 、、--------------------------------
// Session["StudentID"] = jie["StudentID"];
if(jie.Read())
{
this.UserID.Text = Session["UserID"].ToString().Trim();
this.Question.Text = jie["Question"].ToString().Trim();
this.Answer.Text = jie["Answer"].ToString();
this.NickName.Text = jie["NickName"].ToString().Trim();
//TextBox1.Attributes("value")="123456"
this.Password.Attributes["value"] = jie["PWD"].ToString().Trim();
this.CheckPwd.Attributes["value"] = jie["PWD"].ToString().Trim();
this.Address.Text = jie["Address"].ToString().Trim();
this.Post.Text = jie["PostNum"].ToString().Trim();
this.Tele.Text = jie["Tele"].ToString().Trim();
this.Mobile.Text = jie["MobilePh"].ToString().Trim();
this.Email.Text = jie["Email"].ToString().Trim();
this.QQ.Text = jie["QQ"].ToString().Trim();
this.Remark.Text = jie["Remark"].ToString().Trim();
this.Year.SelectedIndex = Convert.ToInt16(jie["biryear"].ToString()) - 1900;
this.Mounth.SelectedIndex = Convert.ToInt16(jie["birmounth"].ToString()) - 1;
string mth = Convert.ToString(Convert.ToInt16(jie["birmounth"].ToString()));
day(mth, Convert.ToInt16(jie["biryear"].ToString()));
this.Day.SelectedIndex = Convert.ToInt16(jie["birday"].ToString()) - 1;
this.Figure.SelectedIndex = picinit(jie["PicName"].ToString());
this.PicLink.Text = " 头像列表 <img id=\"SelPic\" alt=\"\" src=\"HeadPic/" + piclinkinit(jie["PicName"].ToString()) + "\" style=\"width: 46px; height: 43px ;border-top-style: none; border-right-style: none; border-left-style: none; border-bottom-style: none;\" />";
if (jie["Sex"].ToString().Trim() =="帅哥")
this.Boy.Checked = true;
else
this.Girl.Checked = true;
// this.Country.Attributes["text"] = "dsjkf;";
}
conn.Close();
// cmd.Parameters["@UserID"].Value = this.UserID.Text;
// cmd.Parameters["@StudentID"].Value = this.SorT_ID.Text;
// cmd.Parameters["@PWD"].Value = this.Password.Text;
// cmd.Parameters["@NickName"].Value = this.NickName.Text;
// cmd.Parameters["@Question"].Value = this.Question.Text;
// cmd.Parameters["@Answer"].Value = this.Answer.Text;
// cmd.Parameters["@PicName"].Value = "~/HeadPic/" + this.Figure.SelectedItem.Text ;
// cmd.Parameters["@Remark"].Value = this.Remark.Text;
// if(this.Boy.Checked==true)
// cmd.Parameters["@Sex"].Value=this.Boy.Text;
// else
// cmd.Parameters["@Sex"].Value = this.Girl.Text;
//cmd.Parameters["@Tele"].Value = this.Tele.Text;
//cmd.Parameters["@MobilePh"].Value = this.Mobile.Text;
//cmd.Parameters["@QQ"].Value = this.QQ.Text;
//cmd.Parameters["@Email"].Value = this.Email.Text;
//cmd.Parameters["@Country"].Value = this.Country.SelectedItem.Text;
//cmd.Parameters["@Province"].Value = this.Province.SelectedItem.Text;
//// this.City.SelectedItem.Text;IdToCity(strcity)
//cmd.Parameters["@City"].Value = strcity ;
// ////////////////////////////
//cmd.Parameters["@Address"].Value = this.Address.Text;
//cmd.Parameters["@PostNum"].Value = this.Post.Text;
//cmd.Parameters["@RegClass"].Value = "";
//cmd.Parameters["@biryear"].Value = this.Year.Text;
//cmd.Parameters["@birmounth"].Value = this.Mounth.Text;
//cmd.Parameters["@birday"].Value = this.Day.Text;
//--------------------------------------------------------------------------------------------
}
public int picinit(string str)
{
//~/HeadPic/image1.gif
string temp = str.Substring(15, 1);
return Convert.ToInt32(temp)-1;
}
public string piclinkinit(string str)
{
//~/HeadPic/image1.gif
string temp = str.Substring(10);
return temp.Trim();
}
protected void Update_Click(object sender, EventArgs e)
{
//CREATE PROCEDURE [updateuser]
//(
// @UserID char(20),
//@PWD nchar(16),
//@NickName char(10),
//@Question varchar(50),
//@Answer varchar(50),
//@PicName nchar(30),
//@Remark nvarchar(200),
//@Sex char(10),
//@Tele char(20),
//@MobilePh nchar(16),
//@QQ char(10),
//@Email nchar(30),
//@Country char(10),
//@Province char(10),
//@City Char(10),
//@Address nchar(40),
//@PostNum nchar(10),
//@biryear char(10),
//@birmounth char(10),
//@birday char(10)
//)
// AS update UserInfo
//set
//PWD =@PWD ,
//NickName=@NickName,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -