Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Datagrid + display Row number

Posted on 2004-08-16
5
Medium Priority
?
765 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

618 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