Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 允许排序=false不起作用?_C#_Asp.net_Gridview - Fatal编程技术网

C# 允许排序=false不起作用?

C# 允许排序=false不起作用?,c#,asp.net,gridview,C#,Asp.net,Gridview,在我的网格视图中,我想在网格视图的最后一行插入新记录。所以我设置了Gridview2.Allowsorting为false。但它在我的网格视图上不起作用。我的密码在这里 public void gridview2_selectgroup() { if (Session["selectedgroupes"] != null) { ArrayList groups = new ArrayList(); ArrayList student_id_lis

在我的网格视图中,我想在网格视图的最后一行插入新记录。所以我设置了
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();
    }
public void gridview 2\u selectgroup()
{
如果(会话[“SelectedGroup”]!=null)
{
ArrayList组=新的ArrayList();
ArrayList student_id_list=新建ArrayList();
组=(ArrayList)会话[“SelectedGroup”];
学生id列表=(ArrayList)会话[“学生id”];
string select_string=“从student_详细信息中选择student_姓名、student_id、student_权限、student_组,其中student_组=”+组[0]。ToString().Trim()+”;

对于(int i=1;i点击.aspx页面中的gridview并点击f4。属性窗口将弹出。在那里你检查第5行(允许排序)。如果为真,则将其设为假。有时代码隐藏代码由于计时而无法工作。如果已经为假,则将“GridView2.AllowSorting=false;”放在数据源和数据绑定之间

GridView2.DataSource = ds;
GridView2.AllowSorting = false;
GridView2.DataBind();
试试这个

string select_string="SELECT student_id,student_name,student_nric,student_group FROM student_details WHERE student_group='"+groups[0].ToString().Trim()+"' ";

设置AllowSorting=false时要更正/发生什么?在一个正常工作的网格视图上,代码是什么样子的?我想在网格视图的底部显示新插入的记录。但现在它显示在排序格式上。我想避免排序@flopscitifist区别在于,只更改了选择查询。@Brian Rogerswahat如果您在数据绑定之前设置allowsorting=false?我已经按照您的建议做了。但即使它也不起作用@Sasidharan Chandrandid u check.aspx page for yes。我也尝试过这种方法。失败。select命令有问题吗?我只是从表中选择记录到网格视图。@Sasidharan Chandrandid u在该查询中给出一个断点然后复制整个查询并粘贴到此处。让我看看它是如何构建的。即使查询出现问题,我们也会尝试使用存储过程。如果不希望排序,请删除该gridview2。allowsorting=false。Bcoz允许排序的默认值为false。删除该值并检查。此外,您是否收到任何警告或错误。