Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
Reply With Quote
  #3 (permalink)  
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
Reply With Quote
  #4 (permalink)  
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:45 PM.


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