首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否允许sorting=false不起作用?

是否允许sorting=false不起作用?
EN

Stack Overflow用户
提问于 2013-08-14 12:01:48
回答 2查看 456关注 0票数 2

在我的网格视图中,我想在网格视图的最后一行插入新记录。所以我将Gridview2.Allowsorting设置为false。但它在我的网格视图中不起作用。我的代码在这里

代码语言:javascript
复制
 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();
    }

原因会是什么?它在我的项目的另一个网格视图上工作。请帮帮忙

EN

回答 2

Stack Overflow用户

发布于 2013-08-14 13:00:40

在.aspx页面中单击您的网格视图,然后点击f4。将弹出属性窗口。在这里你检查第5行(允许排序).If它的真,使它为假。有时,代码后台代码将不会工作,因为它已经是假的,然后把你的"GridView2.AllowSorting = timings.If;“放在数据源和数据库之间。

代码语言:javascript
复制
GridView2.DataSource = ds;
GridView2.AllowSorting = false;
GridView2.DataBind();
票数 0
EN

Stack Overflow用户

发布于 2013-08-14 14:36:00

尝尝这个

代码语言:javascript
复制
string select_string="SELECT student_id,student_name,student_nric,student_group FROM student_details WHERE student_group='"+groups[0].ToString().Trim()+"' ";
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18222980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档