Link to home
Start Free TrialLog in
Avatar of Padre_Corleone
Padre_CorleoneFlag for United States of America

asked on

Gridview Databinding help

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++;
                }
            }
Avatar of DreamMaster
DreamMaster

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.
Avatar of Padre_Corleone

ASKER

RoleNames is the only Column return, how can i also get RoleID, CreatedDate
to display on my gridview?
ASKER CERTIFIED SOLUTION
Avatar of DreamMaster
DreamMaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad to have been helpful :)

Regards,
Max.