C# Web gridview sortin
- by tommypiaa
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();
}