如何配置 ASP.NET GridView 以通过 Object DataSource 填充它,其中对象方法需要 noticeCode 以通过 C# 代码传递?
StudentControlPanel.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
string username = (string)Request.QueryString["username"];
Student std = Student.GetStudentByUsername(username);
if (std != null)
{
labName.Text = std.StudentName;
labUsername.Text = username;
labRollNo.Text = std.RollNo;
labRegNo.Text = std.RegNo;
Dept dpt = std.Department;
if (dpt != null)
{
labDepartment.Text = dpt.DeptName;
}
else
{
labDepartment.Text = "?";
}
}
/* Student-class has a SessionCode-property */
/* I need to pass this to Notice.GetNoticesBySessionCode()...*/
}
通知.cs
public class Notice
{
public static List<Notice> GetNoticesBySessionCode(string sessionCode)
{
List<Notice> notices = null;
/* EcecuteReader()..... */
return notices;
}
}