for (int i = 0; i <e.Values.Keys.Count; i++)
{
string a = e.Values[i].ToString();//detailview中取值
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
//GridViewRow selectRow = GridView1.SelectedRow;
//string strId = selectRow.Cells[0].Text;
//Response.Write(strId);
//Response.End();
}
在ing中 GridViewRow selectRow = GridView1.Rows[e.newselectIndex]
TextBox tb = (TextBox)con.FindControl("TextBox1");
但con的值为null,这样后续的语句也不可能执行了。问题出在哪里呢?
经过一番搜索,在forums.asp.net中找到了答案,以下引用的是bitmask的说法:
...becasue the Content controls themselves dissapear after the master page rearranges the page. You can use the ContentPlaceHolders, or the
on the MasterPage if there are no INamingContainers between the form and the control you need.
所以以上的代码应该改成:
TextBox tb = (TextBox)PreviousPage.Master.FindControl("ContentPlaceHolder1").FindControl("TextBox1");
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
if (row.RowState == DataControlRowState.Selected)
{
this.Label3.Text = row.Cells[1].Text.ToString();
this.txt1.Text ="你好";
}
protected void DetailsView1_ModeChanging(Object sender, System.Web.UI.WebControls.DetailsViewModeEventArgs e)
{
if (e.CancelingEdit == true)
{
Response.Redirect("GridViewMasterDetailsInsertPage_cs.aspx");
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
if (e.Exception != null)
{
ErrorMessageLabel.Text = "Failed to DELETE due to foreign key contstraint on the table. You may only delete rows
which have no related records.";
e.ExceptionHandled = true;
}
}

浙公网安备 33010602011771号