C# Web gridview sortin

Posted by tommypiaa on Stack Overflow See other posts from Stack Overflow or by tommypiaa
Published on 2013-10-26T03:50:23Z Indexed on 2013/10/26 3:54 UTC
Read the original article Hit count: 176

Filed under:
|
|
|
|

Any examples how would I enable sorting for the gridview? private void loadlist() { cn.Open(); cmd.CommandText = "select Breed, Name, Image from Animals"; dr = cmd.ExecuteReader(); cn.Close();

    }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        AddData();
        Addimage();

    }

    protected void AddData()
    {
        if (TextBox1.Text != "" & TextBox2.Text != "")
        {
            cn.Open();
            cmd.CommandText = "insert into Animals (Breed, Name) values ('" + TextBox1.Text + "', '" + TextBox2.Text + "')";
            cmd.ExecuteNonQuery();
            cmd.Clone();
            cn.Close();
            loadlist();
        }
    }

    protected void DisplayData()
    {
        cn.Open();
        cmd.CommandText = "select Breed, Name from Animals";
        dr = cmd.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();

        cn.Close();
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about sorting