using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Collections;

public partial class _Default : System.Web.UI.Page
{
List _persons = new List();
protected void Page_Load(object sender, EventArgs e)
{
person person1 = new person();
person1.ID = 1;
person1.Name = "Kiran";
_persons.Add(person1);

person person2 = new person();
person2.ID = 2;
person2.Name = "Avtar";
_persons.Add(person2);

person person3 = new person();
person3.ID = 3;
person3.Name = "Chintan";
_persons.Add(person3);

person _obj= FindPersonOnID(2);
SortPersonOnName();
}
private person FindPersonOnID(int ID)
{
return _persons.Find(delegate(person _Obj) {return _Obj.ID == ID; });
}
private void SortPersonOnName()
{
_persons.Sort(delegate(person _Obj1, person _obj2) { return Comparer.Default.Compare(_Obj1.Name, _obj2.Name); });
}
}
public class person
{
private int _ID;
public int ID
{
get { return _ID; }
set { _ID = value; }
}

private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}
}

Protected Sub DeleteSelectedProducts_Click(sender As Object, e As EventArgs) _
Handles DeleteSelectedProducts.Click

Dim atLeastOneRowDeleted As Boolean = False

' Iterate through the Products.Rows property
For Each row As GridViewRow In Products.Rows
' Access the CheckBox
Dim cb As CheckBox = row.FindControl("ProductSelector")
If cb IsNot Nothing AndAlso cb.Checked Then
' Delete row! (Well, not really...)
atLeastOneRowDeleted = True

' First, get the ProductID for the selected row
Dim productID As Integer = _
Convert.ToInt32(Products.DataKeys(row.RowIndex).Value)

' "Delete" the row
DeleteResults.Text &= String.Format( _
"This would have deleted ProductID {0}
", productID)

'... To actually delete the product, use ...
' Dim productAPI As New ProductsBLL
' productAPI.DeleteProduct(productID)
'............................................
End If
Next

' Show the Label if at least one row was deleted...
DeleteResults.Visible = atLeastOneRowDeleted
End Sub


 

| Modified by Kiran Patel |