0
我想通过下面的代码添加数据:如何添加数据到GridView?
protected void gridview1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Session["BranchingCode"] != null)
{
List<CourseDetail> studentList = Course_Detail.GetStudentListOfBranch(Session["BranchingCode"].ToString(), Session["CurrentSession"].ToString());
if (studentList != null)
{
for (int i = 0; i < studentList.Count(); i++)
{
e.Row.Cells[0].Text = studentList[i].UserNameRoll;
e.Row.Cells[1].Text = studentList[i].StudentName;
}
}
}
GridView1.DataBind();
}
}
但因为没有datasource
附着的GridView,此事件不火。 请告诉我该怎么办? 有没有办法强行启动这个事件或者做其他事情&在其他地方输入数据..?
我不能添加它..它说gridview1不在当前上下文页面加载.. – 2013-02-09 08:30:28