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
Solved

Customize a Role Grid View, bound to Roles.GetAllRoles

Posted on 2009-07-13
2
489 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
jquery datatables, asp.net MVC 9 50
Visual Studios 1 76
Finding Events logs for IIS website that restarts 2 14
VS 2015 is giving [No relevant source lines] 2 24
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…
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.…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

766 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