Sunday, April 11, 2010

GridView with CheckBox for Deleteing the checked Items..

[asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"]                      
[Columns]
   [asp:BoundField DataField="roll_no" HeaderText="Roll No" /]
   [asp:BoundField DataField="s_name" HeaderText="Student Name" /]
   [asp:BoundField DataField="class" HeaderText="Class" /]
     [asp:TemplateField]
  [ItemTemplate]
       [asp:CheckBox ID="ch1" Text='<%# Eval("roll_no") %>' runat="server" /]
   [/ItemTemplate]
      [/asp:TemplateField]
[/Columns]
  [/asp:GridView]


In your .cs file in the class level write this line of code

First Use This Code in Page load
ArrayList alist = new  ArrayList();
protected void Page_Load(object sender, EventArgs e)
{
 if (!Page.IsPostBack)
   {
      //Populate data and Bind in Gridview

      }

   }