2014-01-21 1 views
0

행을 선택하면 해당 값이 다른 gridview 및 텍스트 상자에 채워지는 gridview를 만들고 싶습니다. 하지만 위의 오류가 발생했습니다. GridView2에서 행을 클릭하면 아무 일도 일어나지 않고 sqladapter에서 오류가 발생합니다. C#을개체 유형 System.Web.UI.WebControls.GridViewRow에서 알려진 관리 공급자 네이티브 형식으로의 매핑이 없습니다.

protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) 
{ 
    SqlConnection con = new SqlConnection(conn); 
    SqlCommand com = new SqlCommand("SELECT MRPNo, MRPType, MRPDate FROM MRP WHERE MRPNo = @mrpno",con); 
    com.Parameters.Add("@mrpno", GridView2.SelectedRow); 
    DataTable dt = new DataTable(); 
    SqlDataAdapter sda = new SqlDataAdapter(com); 
    sda.Fill(dt); 
    DataRow row = dt.Rows[0]; 
    txtMRPNo.Text = row["MRPNo"].ToString(); 
    txtMRPDate.Text = row["MRPType"].ToString(); 
    txtMRPDate.Text = row["MRPDate"].ToString(); 
    GridView3.DataBind(); 
    GridView1.DataBind(); 
} 

protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    LinkButton selectButton = new LinkButton() 
    { 
     CommandName = "Select", 
     Text = e.Row.Cells[0].Text, 
    }; 
    e.Row.Cells[0].Controls.Add(selectButton); 
} 

protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e) 
{ 
    if (e.Row.RowType == DataControlRowType.DataRow) 
     { 
      e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';"; 
      e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; 
      e.Row.ToolTip = "Click to select row"; 
      e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView2, "Select$" + e.Row.RowIndex); 
     } 
    } 
} 

답변

관련 문제