Solved

Customize a Role Grid View, bound to Roles.GetAllRoles

Posted on 2009-07-13
2
488 Views
Last Modified: 2012-08-14
Hello,
I have set up membership in an ASP.NET application.

I need to show all the Roles of the application in a GridView GV1.

so wrote in some event :
GV1.DataSource = Roles.GetAllRoles()
GV1.DataBind()

It worked fine, and the Roles are displayed in one column in GV1, having a header of ITEM.
I need to change the header Text to Role for Instance,
How can i do this?
thanks
I am using VB
0
Comment
Question by:Nyana22
  • 2
2 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24845024
This is one way...there might be some more simple way which I might not be aware of:
Use GridView RowDataBound Event like below:

Protected Sub GV1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
    If e.Row.RowType = DataControlRowType.Header Then
        For Each cell As TableCell In e.Row.Cells
            cell.Text = "Role"
        Next
    End If
End Sub

Ref:
http://www.rosshawkins.net/archive/2007/04/15/adding-tooltips-to-gridview-headers.html.aspx
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24845047
My bad...you don't need a For Each loop just set like below:
Assuming it as first column....i.e. index=0...

 If e.Row.RowType = DataControlRowType.Header Then
        e.Row.Cells(0).Text = "Role"
    End If
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.net Fit image buttons according to size of the screen 2 20
How to close an asp.net web form using C# ? 4 30
mail.To.Add 5 25
Disable extension 8 37
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 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