<script type="text/javascript"> function over(t,id) { //col var x var mycol = getElementsById(t,id) for (x in mycol) { if (mycol[x].style.backgroundColor != "red") mycol[x].style.backgroundColor = "#ccffcc"; } }
function out(t,id) { //col var x var mycol = getElementsById(t,id) for (x in mycol) { if (mycol[x].style.backgroundColor != "red") mycol[x].style.backgroundColor = "white"; } }
function getElementsById(sId,id) {
var outArray = new Array();
//rows var dt = document.getElementById("dtgView"); for(var j = 0; j < dt.rows.length; j++) { outArray[j] = document.all[sId][j]; }
//columns var d; var cId;
for (var k=0;k<document.all[sId].length-2;k+=1) { cId="TestCol" + k; d = k + (dt.rows.length - 1); outArray[d] = document.all[cId][id]; }
return outArray; } </script> <asp:datagrid id="dtgView" AutoGenerateColumns="true" Runat="server"></asp:datagrid>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim d As DataTable dtgView.DataSource = d 'Datagrid bind code goes here. d is datasource. do code for this. dtgView.DataBind() End Sub
Private Sub dtgView_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dtgView.ItemDataBound If e.Item.ItemType <> ListItemType.Header Then
Dim k As Integer = 0 For k = 0 To e.Item.Cells.Count - 1 Dim id As String = "TestCol" & k e.Item.Cells(k).Attributes.Add("id", id) e.Item.Cells(k).Attributes.Add("onmouseover", "over('" & id & "'," & e.Item.ItemIndex & ")") e.Item.Cells(k).Attributes.Add("onmouseout", "out('" & id & "'," & e.Item.ItemIndex & ")") Next
End If
End Sub
|
No responses found. Be the first to respond and make money from revenue sharing program.
|