【发布时间】:2013-08-14 04:01:48
【问题描述】:
在我的网格视图中,我想将新记录插入到网格视图的最后一行。所以我设置Gridview2.Allowsorting 是false。但它不适用于我的网格视图。我的代码在这里
public void gridview2_selectgroup()
{
if (Session["selectedgroupes"] != null)
{
ArrayList groups = new ArrayList();
ArrayList student_id_list = new ArrayList();
groups = (ArrayList)Session["selectedgroupes"];
student_id_list=(ArrayList)Session["STUDENT_ID"];
string select_string="SELECT student_name,student_id,student_nric,student_group FROM student_details WHERE student_group='"+groups[0].ToString().Trim()+"' ";
for(int i=1;i<groups.Count;i++)
{
select_string+= " or student_group='"+groups[i].ToString().Trim()+"'";
}
if(Session["STUDENT_ID"]!=null)
{
for(int i=0;i<student_id_list.Count;i++)
{
select_string+= " or student_id='"+student_id_list[i].ToString().Trim()+"'";
}
}
SqlConnection con = obj.getcon();
con.Open();
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(select_string, con);
adapter.Fill(ds);
GridView2.DataSource = ds;
GridView2.AllowSorting = false;
GridView2.DataBind();
con.Close();
}
会是什么原因?它适用于我项目的另一个网格视图。请帮忙
【问题讨论】:
-
设置 AllowSorting=false 时您想更正/发生什么?
-
在其中一个正常工作的网格视图上的代码是什么样的?
-
我想在gridview的底部显示新插入的记录。但现在它以排序格式显示。我想避免这种排序@FlopScientist
-
不同的是,只是选择查询发生了变化。 @布莱恩·罗杰斯
-
如果在数据绑定之前设置alloworting=false会怎样?