简体   繁体   English

从对象类型System.Web.UI.WebControls.GridViewRow到已知托管提供程序本机类型的映射不存在

[英]No mapping exists from object type System.Web.UI.WebControls.GridViewRow to a known managed provider native type

I want to make a gridview that when I select a row, its values will be populated to another gridview and text boxes, but I am encountering the error above. 我想做一个gridview,当我选择一行时,它的值将被填充到另一个gridview和文本框中,但是遇到了上面的错误。 When I click the row in the GridView2, nothing is happening and an error in the sqladapter occurs. 当我单击GridView2中的行时,什么也没有发生,并且sqladapter中发生错误。 Please help me to fix this code.. 请帮助我修复此代码。

Here is my code: c# 这是我的代码:c#

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);
        }
    }
}

You can not use GridView2.SelectedRow as an input to Parameters.Add(). 您不能将GridView2.SelectedRow用作Parameters.Add()的输入。 Please refer to MSDN ( http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow(v=vs.110).aspx ) and you will see why. 请参考MSDN( http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow ( v=vs.110 ) .aspx ),您将看到原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不存在从对象类型 System.Web.UI.WebControls.TextBox 到已知托管提供程序本机类型的映射 - No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type 从对象类型System.Web.UI.WebControls.ListItem到已知托管提供程序本机类型的映射不存在 - No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed provider native type 从对象类型System.Web.UI.WebControls.DropDownList到已知的托管提供程序本机类型没有映射 - No mapping exists from object type System.Web.UI.WebControls.DropDownList to a known managed provider native type 不存在从对象类型System.Web.UI.WebControls.ListItem到具有下拉列表的已知托管提供程序本机类型的映射 - No mapping exists from object type System.Web.UI.WebControls.ListItem to a known managed provider native type with dropdown 错误:从对象类型System.Web.UI.WebControls.TextBox到已知的托管提供程序本机类型的映射不存在 - ERROR: No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type C# 不存在从对象类型 System.Web.UI.WebControls.TextBox 到已知托管提供程序本机类型的映射 - C# No mapping exists from object type System.Web.UI.WebControls.TextBox to a known managed provider native type 无法将类型为“ Obout.Grid.GridTemplate”的对象转换为类型为“ System.Web.UI.WebControls.GridViewRow”的对象。 不解决 - Unable to cast object of type 'Obout.Grid.GridTemplate' to type 'System.Web.UI.WebControls.GridViewRow'. not resolving 无法将类型为“ System.Web.UI.WebControls.ContentPlaceHolder”的对象转换为类型为“ System.Web.UI.WebControls.GridViewRow”的对象 - Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'System.Web.UI.WebControls.GridViewRow' 无法将类型为“ System.Web.UI.HtmlControls.HtmlForm”的对象转换为类型为“ System.Web.UI.WebControls.GridViewRow”的对象 - Unable to cast object of type 'System.Web.UI.HtmlControls.HtmlForm' to type 'System.Web.UI.WebControls.GridViewRow' 不存在从对象类型 System.Text.StringBuilder 到已知托管提供程序本机类型的映射 - No mapping exists from object type System.Text.StringBuilder to a known managed provider native type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM