在我的网格视图中,我想在网格视图的最后一行插入新记录。所以我将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();
}原因会是什么?它在我的项目的另一个网格视图上工作。请帮帮忙
发布于 2013-08-14 13:00:40
在.aspx页面中单击您的网格视图,然后点击f4。将弹出属性窗口。在这里你检查第5行(允许排序).If它的真,使它为假。有时,代码后台代码将不会工作,因为它已经是假的,然后把你的"GridView2.AllowSorting = timings.If;“放在数据源和数据库之间。
GridView2.DataSource = ds;
GridView2.AllowSorting = false;
GridView2.DataBind();发布于 2013-08-14 14:36:00
尝尝这个
string select_string="SELECT student_id,student_name,student_nric,student_group FROM student_details WHERE student_group='"+groups[0].ToString().Trim()+"' ";https://stackoverflow.com/questions/18222980
复制相似问题