Solved

Datagrid + display Row number

Posted on 2004-08-16
5
746 Views
Last Modified: 2011-09-20
i have a datagrid that show standings i want to add a colum that wil display the number of the row ie 1 thru 10, plus also when the use goes to the standings i want their name bold so it stands out, i will get their name form the authentication cookie and it will match the name colum

ie

Position     Name       Pts
1              abcd         10
2              efghk         9
3              keyname    8   <-- currently logged in so this would be highlighted.

Thanks
0
Comment
Question by:dkilby
  • 2
  • 2
5 Comments
 

Author Comment

by:dkilby
ID: 11817620
sorry forgot to add, i am using VB.net
0
 
LVL 21

Accepted Solution

by:
tovvenki earned 250 total points
ID: 11817775
Hi,
for row numbers add a template column as the first column of the grid. As each row is rendered, the code behind the OnItemCreate event will update the text of this column based on the row index from the dataset. Each row of the dataset has an index property that can be used to compute the row number:

Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            e.Item.Cells(0).Text = (e.Item.DataSetIndex + 1).ToString()
        End If

    End Sub

Regards,
venki
0
 

Author Comment

by:dkilby
ID: 11820654
I
0
 
LVL 10

Assisted Solution

by:jnhorst
jnhorst earned 250 total points
ID: 11826182
adding to tovvenki's post:

then check the name against your auth cookie and add <b> & </b> tags to the text of the name cell.  In your sample above, Name is the second column so I will assume the index of the column is 1.

If {authCookie value} = e.Item.Cells(1).Text Then
     e.Item.Cells(1).Text = "<b>" & e.Item.Cells(1).Text & "</b>"
End If

John
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 11827483
Hi,
I am sorry I missed that one. jnhorst is correct add that too.

Regards,
venki
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now