62,269
社区成员
发帖
与我相关
我的任务
分享
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bjd();
}
}
public void bjd()
{
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn5 = new SqlConnection(myStc);
conn5.Open();
SqlCommand cmd5 = new SqlCommand("select * from tb_bjd", conn5);
SqlDataReader sdr5 = cmd5.ExecuteReader();
sdr5.Read();
if (sdr5["cpht"].ToString() == "是")
this.cpht.Checked = true;
else
this.cpht.Checked = false;
this.TextBox1.Text = sdr5["bjd_no"].ToString();
this.TextBox2.Text = sdr5["kh_no"].ToString();
this.TextBox3.Text = sdr5["kh_adress"].ToString();
this.TextBox4.Text = sdr5["kh_tel"].ToString();
this.TextBox5.Text = sdr5["zbj"].ToString();
this.YYSimpleCalendar2.Text = sdr5["kd_date"].ToString();
this.TextBox6.Text = sdr5["kh_name"].ToString();
this.TextBox7.Text = sdr5["kh_linkman"].ToString();
this.TextBox8.Text = sdr5["kh_fax"].ToString();
this.zk.Text = sdr5["z_zk"].ToString();
this.YYSimpleCalendar1.Text = sdr5["sh_date"].ToString();
conn5.Close();
}
///*************************此段读到datatable*******************
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn = new SqlConnection(myStc);
conn.Open();
string strSql = "select * from tb_bjd";
SqlDataAdapter adp = new SqlDataAdapter(strSql, conn);
DataSet ds = new DataSet();
adp.Fill(ds, "tb_bjd");
///***********************************************************************************************
this.ViewState.Add("dt", dt);
this.ViewState.Add("showi", 0);
dt.Dispose();
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
///*************************此段读到datatable手打,不知道对错*******************
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn = new SqlConnection(myStc);
conn.Open();
strSql = "select * from tb_bjd";
SqlDataAdapter adp = new SqlDataAdapter(strSql, conn);
DataSet ds = new DataSet();
adp.Fill(ds, "tb_bjd");
///***********************************************************************************************
this.ViewState.Add("dt", dt);
this.ViewState.Add("showi", 0);
dt.Dispose();
bjd();
}
}
//绑定
public void bjd()
{
DataTable dt = (DataTable)this.ViewState["dt"];
int showi = (int)this.ViewState["showi"];
if (showi >= 0 && showi < dt.Rows.Count)
{
DataRow sdr5 = dt.Rows[showi];
if (sdr5["cpht"].ToString() == "是")
this.cpht.Checked = true;
else
this.cpht.Checked = false;
this.TextBox1.Text = sdr5["bjd_no"].ToString();
this.TextBox2.Text = sdr5["kh_no"].ToString();
this.TextBox3.Text = sdr5["kh_adress"].ToString();
this.TextBox4.Text = sdr5["kh_tel"].ToString();
this.TextBox5.Text = sdr5["zbj"].ToString();
this.YYSimpleCalendar2.Text = sdr5["kd_date"].ToString();
this.TextBox6.Text = sdr5["kh_name"].ToString();
this.TextBox7.Text = sdr5["kh_linkman"].ToString();
this.TextBox8.Text = sdr5["kh_fax"].ToString();
this.zk.Text = sdr5["z_zk"].ToString();
this.YYSimpleCalendar1.Text = sdr5["sh_date"].ToString();
}
dt.Dispose();
}
//下一行
private void nextr()
{
int showi = (int)this.ViewState["showi"] + 1;
DataTable dt = (DataTable)this.ViewState["dt"];
if (showi >= dt.Rows.Count)
{
showi = dt.Rows.Count - 1;
}
dt.Dispose();
this.ViewState.Add("showi", showi);
bjd();
}
//前一行
private void beforer()
{
int showi = (int)this.ViewState["showi"] - 1;
if (showi < 0)
{
showi = 0;
}
this.ViewState.Add("showi", showi);
bjd();
}
//首行
private void firstr()
{
this.ViewState.Add("showi", 0);
bjd();
}
//末行
private void lastr()
{
DataTable dt = (DataTable)this.ViewState["dt"];
this.ViewState.Add("showi", dt.Rows.Count-1);
dt.Dispose();
bjd();
}
protected void nextBtn_Click(object sender, EventArgs e)
{
nextr();
}
}
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn5 = new SqlConnection(myStc);
conn5.Open();
//SqlCommand cmd5 = new SqlCommand("select * from tb_bjd", conn5);
DataTable dt = new DataTable("select * from tb_bjd");//读出来datatable,不要datareader
this.ViewState.Add("dt", dt);
this.ViewState.Add("showi", 0);
dt.Dispose();
conn5.Close();
bjd();
bjd_mx();
gvSearchBind();
}
}
public void bjd()
{
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn5 = new SqlConnection(myStc);
conn5.Open();
SqlCommand cmd5 = new SqlCommand("select * from tb_bjd", conn5);
//SqlDataReader sdr5 = cmd5.ExecuteReader();
// sdr5.Read();
DataTable dt = (DataTable)this.ViewState["dt"];
int showi = (int)this.ViewState["showi"];
if (showi >= 0 && showi < dt.Rows.Count)
{
DataRow sdr5 = dt.Rows[showi];
// this.DropDownList1.Items.Add(new ListItem(sdr5["typeName"].ToString(), sdr5["typeName"].ToString()));
if (sdr5["cpht"].ToString() == "是")
this.cpht.Checked = true;
else
this.cpht.Checked = false;
this.TextBox1.Text = sdr5["bjd_no"].ToString();
this.TextBox2.Text = sdr5["kh_no"].ToString();
this.TextBox3.Text = sdr5["kh_adress"].ToString();
this.TextBox4.Text = sdr5["kh_tel"].ToString();
this.TextBox5.Text = sdr5["zbj"].ToString();
this.YYSimpleCalendar2.Text = sdr5["kd_date"].ToString();
this.TextBox6.Text = sdr5["kh_name"].ToString();
this.TextBox7.Text = sdr5["kh_linkman"].ToString();
this.TextBox8.Text = sdr5["kh_fax"].ToString();
this.zk.Text = sdr5["z_zk"].ToString();
this.YYSimpleCalendar1.Text = sdr5["sh_date"].ToString();
}
dt.Dispose();
conn5.Close();
}
public void bjd_mx()
{
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn5 = new SqlConnection(myStc);
conn5.Open();
SqlCommand cmd5 = new SqlCommand("select * from bjd_zc", conn5);
SqlDataReader sdr5 = cmd5.ExecuteReader();
sdr5.Read();
// this.DropDownList1.Items.Add(new ListItem(sdr5["typeName"].ToString(), sdr5["typeName"].ToString()));
this.TextBox9.Text = sdr5["wp_no"].ToString();
this.TextBox16.Text = sdr5["wp_name"].ToString();
this.TextBox12.Text = sdr5["wp_num"].ToString();
this.TextBox13.Text = sdr5["page"].ToString();
this.TextBox11.Text = sdr5["wp_jg"].ToString();
this.TextBox17.Text = sdr5["page_jr"].ToString();
this.TextBox14.Text = sdr5["cp_zk"].ToString();
this.YYSimpleCalendar3.Text = sdr5["cp_jh_date"].ToString();
conn5.Close();
}
public void gvSearchBind()
{
string strSql;
string myStc = ConfigurationManager.AppSettings["ConnectionString"].ToString();
SqlConnection conn = new SqlConnection(myStc);
conn.Open();
strSql = "select * from bjd_zc where bjd_no='"+TextBox1.Text+"'";
SqlDataAdapter adp = new SqlDataAdapter(strSql, conn);
DataSet ds = new DataSet();
adp.Fill(ds, "bjd_zc");
GridView1.DataSource = ds.Tables["bjd_zc"].DefaultView;
GridView1.DataBind();
}
protected void piorBtn_Click(object sender, EventArgs e)
{
}
protected void nextBtn_Click(object sender, EventArgs e)
{
int showi = (int)this.ViewState["showi"] + 1;
DataTable dt = (DataTable)this.ViewState["dt"];
if (showi >= dt.Rows.Count)
{
showi = dt.Rows.Count - 1;
}
dt.Dispose();
this.ViewState.Add("showi", showi);
}
}
public partial class MyPrograme : System.Web.UI.Page
{
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
ViewState["currentNo"] = 0;//保留当前的行号
SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from youTable", myConn);
ds = new DataSet();
da.Fill(ds);
}
//上一条
protected void Button1_Click(object sender, EventArgs e)
{
if (Convert.ToInt16(ViewState["currentNo"]) == 0)
TextBox1.Text = ds.Tables[0].Rows[0]["id"].ToString();
else
{
TextBox1.Text = ds.Tables[0].Rows[Convert.ToInt16(ViewState["currentNo"]) + -1]["id"].ToString();
ViewState["currentNo"] = Convert.ToInt16(ViewState["currentNo"]) - 1;//保留当前的行号
}
}
//下一条
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = ds.Tables[0].Rows[Convert.ToInt16(ViewState["currentNo"])+1]["id"].ToString();
ViewState["currentNo"] = Convert.ToInt16(ViewState["currentNo"])+1;//保留当前的行号
}
} if (!IsPostBack)
{
DataTable dt = new DataTable();//读出来datatable,不要datareader
this.ViewState.Add("dt", dt);
this.ViewState.Add("showi", 0);
dt.Dispose();
bjd();
}
}
private void bjd()
{
DataTable dt = (DataTable)this.ViewState["dt"];
int showi = (int)this.ViewState["showi"];
if (showi >= 0 && showi < dt.Rows.Count)
{
DataRow dr = dt.Rows[showi];
this.txtFied1.Text = dr["kh_adress"].ToString();
//..........
}
dt.Dispose();
}
private void nextr()
{
int showi = (int)this.ViewState["showi"] + 1;
DataTable dt = (DataTable)this.ViewState["dt"];
if (showi >= dt.Rows.Count)
{
showi = dt.Rows.Count - 1;
}
dt.Dispose();
this.ViewState.Add("showi", showi);
}
private void beforer()
{
int showi = (int)this.ViewState["showi"] - 1;
if (showi < 0)
{
showi = 0;
}
this.ViewState.Add("showi", showi);
}
public static DataTable dt;
public static int i=0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dt= DBAccess.ExecuteQuery_Table("SELECT * FROM tb_bjd");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
i = 0;
Label1.Text = dt.Rows[i][1].ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
i ++;
Label1.Text = dt.Rows[i][1].ToString();
}
protected void Button3_Click(object sender, EventArgs e)
{
i--;
Label1.Text = dt.Rows[i][1].ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{
i = dt.Rows.Count-1;
Label1.Text = dt.Rows[i][1].ToString();
}