Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2008, 11:57 PM
Authorized User
 
Join Date: May 2008
Location: secunderabad, Andhra Pradesh, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to veda
Default binding GridView at runtime!

Depening on the role at runttime the GridView should bind to different SqlDataSources.I searched in Google alreday,but not clear.Can anyone please help me?Can anyone complete following,Becoz following code will not work at all,it doesnot give error ,but it will not run also!

             if (Roles.IsUserInRole("supervisor"))
        {
            GridView4.DataMember=default;
            GridView4.DataSource=SqlDataSource1;
        }


Vedavathi
__________________
Vedavathi
 
Old July 31st, 2008, 06:26 AM
Authorized User
 
Join Date: Jan 2008
Location: Chandigarh, Punjab, India.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Harjinder
Default

Hi Use this
if (Roles.IsUserInRole("supervisor"))
{
GridView4.DataMember=default;
GridView4.DataSource=SqlDataSource1;
GridView4.DataBind();
}


harjinder
 
Old August 4th, 2008, 02:35 AM
Authorized User
 
Join Date: May 2008
Location: secunderabad, Andhra Pradesh, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to veda
Default

Hi Friend,
   Thank U for suggesting..but that doesnot work...If i give DefaultView I get error,If I keep that in comment ,it doesnot display anything.I ned this solution badly.
Here is my code in page_load :----------------

if (Roles.IsUserInRole("employee"))
        {

                //GridView1.DataMember=DefaultView ;
                 GridView1.DataSource=SqlDataSource1;
                 GridView1.DataBind();
             }
         if (Roles.IsUserInRole("hr"))
             {

              // GridView1.DataMember = DefaultView;
                 GridView1.DataSource=SqlDataSource2;
                 GridView1.DataBind();
             }


Vedavathi
 
Old August 4th, 2008, 06:44 AM
Authorized User
 
Join Date: May 2008
Location: secunderabad, Andhra Pradesh, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to veda
Default

I got it!!!!!!
      Credit goes to u by 50%,harjinder.Here is the code to be written in different roles.I have 5 roles.

 GridView1.AutoGenerateColumns = true;
            GridView1.DataSource = SqlDataSource4;
            GridView1.DataBind();

Vedavathi




Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView binding with Arraylist myself.panku .NET Framework 2.0 2 November 5th, 2008 05:52 AM
Binding GridView to ObjectDataSource which... rsearing ASP.NET 2.0 Professional 15 July 9th, 2008 01:44 AM
Gridview problem in Binding ndramkumar ASP.NET 2.0 Professional 1 September 2nd, 2007 11:45 PM
Binding dropdownlist to gridView mcgarry101 ASP.NET 2.0 Basics 0 February 13th, 2007 07:12 AM
Binding fields on a gridview aldwinenriquez ASP.NET 2.0 Professional 0 June 1st, 2006 07:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.