?
Solved

Gridview Databinding help

Posted on 2007-04-05
4
Medium Priority
?
348 Views
Last Modified: 2008-01-09
I have a databind that returns all roles, the problem is would like to customize this control so that the actual role has all other columns included for example roleid, rolename, roledate etc.

the following only returns all roles and the header name is "item"
gvRoles.DataSource = System.Web.Security.Roles.GetAllRoles
gvRoles.DataBind()

    <asp:GridView ID="gvRoles" runat="server" AutoGenerateColumns="true" AutoGenerateDeleteButton="true" AutoGenerateEditButton="true" AutoGenerateSelectButton="true">
                        </asp:GridView>

 SqlDataAdapter Adapter = new SqlDataAdapter(Command);
            DataSet RolesDS = new DataSet();
            try
            {
                SqlConn.Open();
                Adapter.Fill(RolesDS);
                int i = 0;
                roles = new string[RolesDS.Tables[0].Rows.Count];
                foreach (DataRow role in RolesDS.Tables[0].Rows)
                {
                    roles[i] = role["RoleNames"].ToString();
                    i++;
                }
            }
0
Comment
Question by:Padre_Corleone
[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
  • 3
4 Comments
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18862672
I'm not exactly sure if I know what you mean. When you say "actual role" do you mean the selected role?

Cause in that case you will probably need to extend upon the gridview control, so that you have a different look for a selected row, or even a mouseover row for that matter.

Is that what you mean or am I totally off base here.

Regards,
Max.
0
 
LVL 7

Author Comment

by:Padre_Corleone
ID: 18862675
RoleNames is the only Column return, how can i also get RoleID, CreatedDate
to display on my gridview?
0
 
LVL 19

Accepted Solution

by:
DreamMaster earned 2000 total points
ID: 18862773
You will have to also return them, just don't display them, so instead of using autogeneratecolumns="true" turn it to false and use binding of columns to show what you want.

If you do that, you can show Rolenames by default and you will need to write some logic to make sure that when selected you also show RoleID and CreatedDate..

Regards,
Max.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 18862902
Glad to have been helpful :)

Regards,
Max.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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