尝试投射到我的班级时,我得到以下信息:无法将“System.Data.DataRowView”类型的对象转换为“QuestionBuilder”类型。
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
Line 204: else if(e.Row.RowType== DataControlRowType.DataRow)
Line 205: {
Line 206: QuestionBuilder drv = (QuestionBuilder)e.Row.DataItem;
Line 207:
Line 208: }
MY CLASS:
==================================================== =
[Serializable]
public class QuestionBuilder
{
/// Field for connection string
/// </summary>
private string connectionstring = Connection.GetConnecionString();
public string QuestionText
{
get;
set;
}
public string DataTypeId
{
get;
set;
}
public string DynamicAttributeId
{
get;
set;
}
public object DynamicValue
{
get;
set;
}
public string SortOrder
{
get;
set;
}
public string ProjectID
{
get;
set;
}
public string DataTypeName
{
get;
set;
}
public bool QuestionID
{
get;
set;
}
public int surveyID
{
get;
set;
}
public string ID
{
get;
set;
}
public string dateteupdated
{
get;
set;
}
public string recordstatus
{
get;
set;
}
public string modifiedby
{
get;
set;
}
public string changereason
{
get;
set;
}
public bool Required
{
get;
set;
}
public string SectionName
{
get;
set;
}
public int SectionID
{
get;
set;
}
public string FormType
{
get;
set;
}
public int DecisionsetID
{
get;
set;
}
public int SurveyID
{
get;
set;
}
=========================================================
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.CssClass = "casetableheaderstudyList";
}
}
else if(e.Row.RowType== DataControlRowType.DataRow)
{
QuestionBuilder drv = QuestionBuilder)e.Row.DataItem;
}
else
{
foreach (TableCell tc in e.Row.Cells)
{
tc.BorderStyle = BorderStyle.None;
tc.BorderWidth = 0;
//tc.BorderColor = System.Drawing.Color.Transparent;
tc.CssClass = "casetableColumsStudyList";
}
}