SUB Page_Load (Sender
As Object, e
As Eventargs)
Bindgrid ()
End Sub
Sub bindgrid ()
DIM MyConnection
AS
New SqlConnection (ConfigurationSettings.AppSettings ("Coltataspalliance"))
DIM MyDataAdpater
AS
New SqldataAdapter ("
SELECT TOP 10 * from cool_products ", myconnection)
DIM MyDataSet
AS Dataset
Try
MyDataSet =
New dataset ()
'----------------------------------
'Fill The Dataset for the DataBinding of the 2 DataGrid
'----------------------------------
MyDataAdPater.Fill (MyDataSet)
DataGrid1.datasource = MyDataSet
DataGrid1.databind ()
DataGrid2.datasource = MyDataSet
DataGrid2.Database
Catch SQLEX
As sqlexception: response.write (Sqlex.Message.toString ())
Catch EX
As Exception: Response.write (ex.Message.toString ())
END TRY
End Sub
Sub DataGrid1_ItemDatabase (byval sender)
As Object, ByVal E
As system.web.ui.webcontrols.dataGriditeMeventArgs)
If E.Item.ItemType = ListItemType.Item
OR_
E.Item.itemType = ListiteMType.AlternatingItem
THEN
'------------------------------------- -
'Add the onmouseover and onmouseout method to the rotory
'------------------------------------- -
E.Item.attributes.add ("onmouseover", "this.style.backgroundcolor =
'Silver' ")
E.Item.attributes.add ("onmouseout", "this.style.backgroundcolor =
'White' ")
END IF
End Sub
Sub DataGrid2_ItemDatabase (byval sender)
As Object, ByVal E
As system.web.ui.webcontrols.dataGriditeMeventArgs)
If E.Item.ItemType = ListItemType.Item
OR_
E.Item.itemType = ListiteMType.AlternatingItem
THEN
'------------------------------------- - 'Add the onmouseover and onmouseout Method a cell (column) of datagrid
'------------------------------------- -
E.Item.cells (1) .attributes.add ("onmouseover", "this.style.BackGroundColor =
'#Ddeeff' ")
E.Item.cells (1) .attributes.add ("onmouseout", "this.style.backcolor =
'White' ")
'------------------------------------- -
'Change The Mouse Cursor of a Particular Cell (Column) of DataGrid
'(Or you may do it for a whole row of data ")
'------------------------------------- -
E.Item.cells (3) .style ("cursoor") = "hand"
'------------------------------------- -
'Add the onclick alert messagebox to a particular cell (column) of datagrid
'------------------------------------- -
E.Item.cells (3) .attributes.add ("onclick", "Alert ('You Click At ID:" & E.Item.cells (0) .text & ");")
END IF
End Sub
script>