错误:无法将方法组'CopyToDataTable'转换为非委托类型'System.Data.DataTable'。你打算调用这个方法吗?

时间:2013-10-15 13:25:54

标签: c# asp.net datatable

你好如何解决这个问题?我试图在我的rowdatabound事件

中执行此操作
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();
    }
}

1 个答案:

答案 0 :(得分:0)

CopyToDataTable是一种方法,您需要将parenthesys添加到方法名称

dtChoice_2 = dtChoice.Select("QuestionID = '" + QNo + "'").CopyToDataTable();
                                                                           ^^^