嗨如何解決這個問題?我試圖錯誤:無法將方法組'CopyToDataTable'轉換爲非委託類型'System.Data.DataTable'。你打算採用這種方法嗎?
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();
}
}
其中'dtChoice'定義我的RowDataBound事件中執行呢? –
你在哪裏宣佈並初始化'dtChoice'? –
變量'dtChoice'沒有設置爲任何值,甚至沒有在該方法中定義。它是否被聲明爲aspx.cs類的字段? –