新手学习中遇到的一个问题,烦请各位帮帮忙,先谢啦~
*************************************************
A 页面的中我定义了一个GridView (已经RowDataBound) 使用了
<asp:HyperLinkField DataNavigateUrlFields="CompanyID" HeaderText="编辑" Text="编辑" DataNavigateUrlFormatString="ComInfWeb-Editor.aspx?comm={0} "Visible="true" />如何向B 页面的各个TextBox传值?
*************************************************
A 页面已经写的方法 如下
namespace CompanyInfor
{
public partial class ComInfWeb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = 0; if (!IsPostBack)
{
if (Request.QueryString["com"] != null)
{
id = int.Parse(Request.QueryString["com"].ToString()); ComInformation delIdInf = new ComInformation(); CompanyInformationAccess delIdInfAcc = new CompanyInformationAccess(); delIdInf.CompanyID = id; bool getdel = delIdInfAcc.del(delIdInf.CompanyID);
GridViewTest();
}
//if (Request.QueryString["com"] != null)
//{
// id = int.Parse(Request.QueryString["com"].ToString()); // ComInformation selIdInf = new ComInformation(); // CompanyInformationAccess selIdInfAcc = new CompanyInformationAccess(); // selIdInf.CompanyID = id; // DataTable getdel = selIdInfAcc.sel(selIdInf.CompanyID);
//}
}
} /// <summary>
/// 添加信息 绑定GridView 并清空TextBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnYes_Click(object sender, EventArgs e)
{
ComInformation addInf = new ComInformation();
CompanyInformationAccess addInfAcc = new CompanyInformationAccess(); int addID = int.Parse(Request.Form["txtID"]);
string addName = Request.Form["txtName"];
string addPerson = Request.Form["txtJuridicalPerson"];
string addAddress = Request.Form["txtAddress"];
string addTel = Request.Form["txtTel"];
DateTime addTime = DateTime.Parse(Request.Form["txtRgeistrationTime"]);
int addMoney = int.Parse(Request.Form["txtMoney"]);
string addScope = Request.Form["txtBusinessScope"];
int addNumbers = Convert.ToInt32(Request.Form["txtEmployNumber"]);
addInf.CompanyID = addID;
addInf.CompanyName = addName;
addInf.CompanyJuridicalPerson = addPerson;
addInf.CompanyAddress = addAddress;
addInf.CompanyTel = addTel;
addInf.RgeistrationTime = addTime;
addInf.RgeistrationMoney = addMoney;
addInf.BusinessScope = addScope;
addInf.EmployNumber = addNumbers; bool getAdd = addInfAcc.AddComInf(addInf);
GridViewTest(); txtID.Text = "";
txtName.Text = "";
txtJuridicalPerson.Text = "";
txtAddress.Text = "";
txtTel.Text = "";
txtRgeistrationTime.Text = "";
txtMoney.Text = "";
txtBusinessScope.Text = "";
txtEmployNumber.Text = ""; } /// <summary>
/// 清除信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNo_Click(object sender, EventArgs e)
{
txtID.Text = "";
txtName.Text = "";
txtJuridicalPerson.Text = "";
txtAddress.Text = "";
txtTel.Text = "";
txtRgeistrationTime.Text = "";
txtMoney.Text = "";
txtBusinessScope.Text = "";
txtEmployNumber.Text = ""; GridViewTest();
} /// <summary>
/// 通过ID删除 并绑定GridView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
ComInformation delIdInf = new ComInformation();
CompanyInformationAccess delIdInfAcc = new CompanyInformationAccess(); int delID = int.Parse(Request.Form["txtID"]);
delIdInf.CompanyID = delID;
bool getdel = delIdInfAcc.del(delIdInf.CompanyID); GridViewTest(); } /// <summary>
/// 绑定GridView
/// </summary>
private void GridViewTest()
{
ComInformation appnew = new ComInformation();
CompanyInformationAccess Anew = new CompanyInformationAccess();
DataTable dr = new DataTable();
dr = Anew.SelComInf(); gdvTest.DataSource = dr; //获得数据源
gdvTest.DataBind(); //绑定数据
} /// <summary>
/// GridView RowDataBound
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gdvTest_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Text = "******"; string companyid = e.Row.Cells[0].Text;
int comId = int.Parse(companyid);
if (comId % 2 == 0)
{
e.Row.Attributes.Add("style", "background-color:#CAE1FF;");
}
}
}
}
}*****************************************************
B 页面
*************************************************
A 页面的中我定义了一个GridView (已经RowDataBound) 使用了
<asp:HyperLinkField DataNavigateUrlFields="CompanyID" HeaderText="编辑" Text="编辑" DataNavigateUrlFormatString="ComInfWeb-Editor.aspx?comm={0} "Visible="true" />如何向B 页面的各个TextBox传值?
*************************************************
A 页面已经写的方法 如下
namespace CompanyInfor
{
public partial class ComInfWeb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = 0; if (!IsPostBack)
{
if (Request.QueryString["com"] != null)
{
id = int.Parse(Request.QueryString["com"].ToString()); ComInformation delIdInf = new ComInformation(); CompanyInformationAccess delIdInfAcc = new CompanyInformationAccess(); delIdInf.CompanyID = id; bool getdel = delIdInfAcc.del(delIdInf.CompanyID);
GridViewTest();
}
//if (Request.QueryString["com"] != null)
//{
// id = int.Parse(Request.QueryString["com"].ToString()); // ComInformation selIdInf = new ComInformation(); // CompanyInformationAccess selIdInfAcc = new CompanyInformationAccess(); // selIdInf.CompanyID = id; // DataTable getdel = selIdInfAcc.sel(selIdInf.CompanyID);
//}
}
} /// <summary>
/// 添加信息 绑定GridView 并清空TextBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnYes_Click(object sender, EventArgs e)
{
ComInformation addInf = new ComInformation();
CompanyInformationAccess addInfAcc = new CompanyInformationAccess(); int addID = int.Parse(Request.Form["txtID"]);
string addName = Request.Form["txtName"];
string addPerson = Request.Form["txtJuridicalPerson"];
string addAddress = Request.Form["txtAddress"];
string addTel = Request.Form["txtTel"];
DateTime addTime = DateTime.Parse(Request.Form["txtRgeistrationTime"]);
int addMoney = int.Parse(Request.Form["txtMoney"]);
string addScope = Request.Form["txtBusinessScope"];
int addNumbers = Convert.ToInt32(Request.Form["txtEmployNumber"]);
addInf.CompanyID = addID;
addInf.CompanyName = addName;
addInf.CompanyJuridicalPerson = addPerson;
addInf.CompanyAddress = addAddress;
addInf.CompanyTel = addTel;
addInf.RgeistrationTime = addTime;
addInf.RgeistrationMoney = addMoney;
addInf.BusinessScope = addScope;
addInf.EmployNumber = addNumbers; bool getAdd = addInfAcc.AddComInf(addInf);
GridViewTest(); txtID.Text = "";
txtName.Text = "";
txtJuridicalPerson.Text = "";
txtAddress.Text = "";
txtTel.Text = "";
txtRgeistrationTime.Text = "";
txtMoney.Text = "";
txtBusinessScope.Text = "";
txtEmployNumber.Text = ""; } /// <summary>
/// 清除信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNo_Click(object sender, EventArgs e)
{
txtID.Text = "";
txtName.Text = "";
txtJuridicalPerson.Text = "";
txtAddress.Text = "";
txtTel.Text = "";
txtRgeistrationTime.Text = "";
txtMoney.Text = "";
txtBusinessScope.Text = "";
txtEmployNumber.Text = ""; GridViewTest();
} /// <summary>
/// 通过ID删除 并绑定GridView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Button1_Click(object sender, EventArgs e)
{
ComInformation delIdInf = new ComInformation();
CompanyInformationAccess delIdInfAcc = new CompanyInformationAccess(); int delID = int.Parse(Request.Form["txtID"]);
delIdInf.CompanyID = delID;
bool getdel = delIdInfAcc.del(delIdInf.CompanyID); GridViewTest(); } /// <summary>
/// 绑定GridView
/// </summary>
private void GridViewTest()
{
ComInformation appnew = new ComInformation();
CompanyInformationAccess Anew = new CompanyInformationAccess();
DataTable dr = new DataTable();
dr = Anew.SelComInf(); gdvTest.DataSource = dr; //获得数据源
gdvTest.DataBind(); //绑定数据
} /// <summary>
/// GridView RowDataBound
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gdvTest_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Text = "******"; string companyid = e.Row.Cells[0].Text;
int comId = int.Parse(companyid);
if (comId % 2 == 0)
{
e.Row.Attributes.Add("style", "background-color:#CAE1FF;");
}
}
}
}
}*****************************************************
B 页面
解决方案 »
- treeview 绑定数据
- WEB的数据库类 把 connection 对象设置成 static 有什么好处?
- GridView中Header的显示问题……
- 请大家帮我看一下这段代码有没有问题
- 读取用户角色信息在HttpModule中写和在Global.asax中写有什么不同?
- |zyciis| 400分求:如何在ASP.NET中导出的Word文件设置他的页眉 谢谢 急
- 如何在一个Web窗体上,点击一个按钮,出现另一个窗体,本窗体关闭?谢谢!!!
- 急:怎样在一个类文件中写获取当前工程的路径?答对立即给分!
- 如何在程序中实现定时器功能?定时去触发一个事件,这个动作是不是必须放到page_load中呢?
- 各位帮个忙.这个跳转语句对吗?
- aso.net 中类的继承
- MVC 网页小票打印报表打印有没有好的方法或控件
根据内容直接生成标签的数据
相关事件:RowDataBound(- - 应该是这个,没用过gdv)2.前台Js
获取相应的行内数据,循环生成A标签。
代码如下:
*************************************
B 页面代码(.aspx.cs)
namespace CompanyInfor
{
public partial class ComInfWeb_Editor : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
if (Request.QueryString["comm"] != null)
{
int id = int.Parse(Request.QueryString["comm"].ToString()); ComInformation selIdInf = new ComInformation(); CompanyInformationAccess selIdInfAcc = new CompanyInformationAccess(); selIdInf.CompanyID = id; DataTable getsel = selIdInfAcc.sel(selIdInf.CompanyID); txtID.Text = getsel.Rows[0]["CompanyID"].ToString();
txtID.Attributes.Add("readonly", "true");
txtName.Text = getsel.Rows[0]["CompanyName"].ToString();
txtJuridicalPerson.Text = getsel.Rows[0]["CompanyJuridicalPerson"].ToString();
txtAddress.Text = getsel.Rows[0]["CompanyAddress"].ToString();
txtTel.Text = getsel.Rows[0]["CompanyTel"].ToString();
txtRgeistrationTime.Text = getsel.Rows[0]["RgeistrationTime"].ToString();
txtMoney.Text = getsel.Rows[0]["RgeistrationMoney"].ToString();
txtBusinessScope.Text = getsel.Rows[0]["BusinessScope"].ToString();
txtEmployNumber.Text = getsel.Rows[0]["EmployNumber"].ToString(); }
}
}
}
}
ASP.NET页面间传值的几种方式
http://blog.csdn.net/microsoftcenterofhn/article/details/4170404