Solved

Datagrid + display Row number

Posted on 2004-08-16
5
757 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

810 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