C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

Crosshair effect in DataGrid control.


Posted Date: 05 Dec 2007    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Smita D.Member Level: Silver    
Rating: 1 out of 5Points: 10



 
<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





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
DataGrid control.  .  Crosshair effect  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Xml based Dynamic Loading of content and Images with Ajax.Net 2.0
Previous Resource: Dynamically Add Meta Tags in ASP.NET 2.0
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use