日期:2014-05-17 浏览次数:20389 次
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Web.Services; using System.Data.SqlClient; using System.IO; public partial class UserManagement_DepartmentList : System.Web.UI.Page { public SqlDataReader sdr,sdr1,sdr2; public static SqlDataReader sdr3; public Model.Department department; public Service.DepartmentService ds; [WebMethod]//这是一个静态方法,因为有些东西不能用,所以我就在这里面调用下面的普通方法 public static string updateDepart() { string ids=HttpContext.Current.Request["ids"]; UserManagement_DepartmentList departmentlist = new UserManagement_DepartmentList(); departmentlist.selectByIdToName(ids);//在这里调用下面的方法 return ids; } //这是一个非静态的普通方法,测试过没有问题 public void selectByIdToName(string id) { if (Util.StringUtils.isNotBlank(id)) { string[] array = id.Split(",".ToCharArray()); ds = new Service.DepartmentService(); int v; int.TryParse(array[0], out v); sdr2 = ds.selectDepartmentById(v); while (sdr2.Read())//将选择的行id对应的值显示在文本框中 { DropDownList3.SelectedValue = sdr2.GetString(2); TextBox4.Text = sdr2.GetString(2); TextBox5.Text = sdr2.GetString(3); } //Response.Write(DropDownList3.SelectedValue + "|" + TextBox4.Text + "|" + TextBox5.Text); sdr2.Close(); } } }