DataBinding:'System.Data.DataRowView'错误 [英] DataBinding: 'System.Data.DataRowView' error
本文介绍了DataBinding:'System.Data.DataRowView'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个错误DataBinding:'System.Data.DataRowView'不包含名为'StudentName'的属性。,我该如何修复它?
I have this error "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'StudentName'.", how can I fix it ??
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderSubMenu" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolderMainContent" Runat="Server">
<table>
<tr>
<td style="width:150px;">Courses</td>
<td style="width:20px">:</td>
<td>
<asp:DropDownList ID="DropDownListCourses" runat="server"></asp:DropDownList>
</td>
</tr>
<tr>
<td style="width:150px;"></td>
<td style="width:20px"></td>
<td>
<asp:Button ID="ButtonView" runat="server" Text="Veiw"
onclick="ButtonView_Click"/>
</td>
</tr>
</table>
<div style="padding-top:30px"></div>
<table>
<asp:Repeater ID="RepeaterDataVeiw" runat="server">
<HeaderTemplate>
<table>
<tr>
<td>Student Name</td>
<td>Course</td>
<td>Subject</td>
<td>Veiw</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("StudentName")%></td>
<td><%#Eval("CourseName")%></td>
<td><%#Eval("SubjectName")%></td>
<td><a href="ListForum.aspx">Forum</a></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td><%#Eval("StudentName")%></td>
<td><%#Eval("CourseName")%></td>
<td><%#Eval("SubjectName")%></td>
<td><a href="ListForum.aspx">Forum</a></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</table>
</asp:Content>
public partial class Student_ListCourses : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
System.Data.DataTable dt;
BusinessLayer.CoursesController oCourse = new BusinessLayer.CoursesController();
dt = oCourse.Select();
DropDownListCourses.DataSource = dt;
DropDownListCourses.DataValueField = "CourseID";
DropDownListCourses.DataTextField = "CourseName";
DropDownListCourses.DataBind();
}
}
catch (Exception ex)
{ }
}
protected void ButtonView_Click(object sender, EventArgs e)
{
try
{
System.Data.DataTable dt;
BusinessLayer.SubjectsController oCourse = new BusinessLayer.SubjectsController();
oCourse.CourseID = int.Parse(DropDownListCourses.SelectedValue);
dt = oCourse.Select();
RepeaterDataVeiw.DataSource = dt;
RepeaterDataVeiw.DataBind();
}
catch (Exception ex)
{ }
}
}
推荐答案
真的吗?错误告诉您的是,您的数据库查询未返回任何名为StudentName的列。你觉得你应该怎么做?你怎么诊断这个小问题?
Really?? What the error is telling you is that your database query didn't return anything with a column called "StudentName". What you do think you should do about that? How would you diagnose that little problem?
这篇关于DataBinding:'System.Data.DataRowView'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文