错误: 无法将方法组“CopyToDataTable”转换为非委托类型“System.Data.DataTable”.是

本文关键字:类型 System DataTable Data 转换 方法 错误 CopyToDataTable | 更新日期: 2023-09-27 18:35:31

嗨,如何解决这个问题?我试图在我的行数据绑定事件中执行它

protected void RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgse)
{
    if (e.Row.RowType == DataControlRowType.DataRow) {
    //If str = "0" Then
    string QNo = "";
    QNo = e.Row.Cells[0].Text;
        DataTable dtChoice_2;
        dtChoice_2 = dtChoice_2.Select("QuestionID = '" + QNo + "'").CopyToDataTable;
        RadioButtonList RadioBtnList = (RadioButtonList)e.Row.FindControl("RdChoices");
        RadioBtnList.DataSource = dtChoice_2;
    RadioBtnList.DataValueField = "ChoiceID";
    RadioBtnList.DataTextField = "ChoiceDescription";
    RadioBtnList.DataBind();
    }
}

错误: 无法将方法组“CopyToDataTable”转换为非委托类型“System.Data.DataTable”.是

CopyToDataTable 是一个方法,需要在方法名中添加括号

dtChoice_2 = dtChoice.Select("QuestionID = '" + QNo + "'").CopyToDataTable();
                                                                           ^^^
相关文章: