Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need to Bind the GridView for Dynamically Loaded User control In Default Page.

Need to Bind the GridView for Dynamically Loaded User control In Default Page.

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johndas
    wrote on last edited by
    #1

    Hi All, i am struck in between the logic. My question is i am loading the user control dynamically as follows. step1: --> In Defalut.aspx.cs--> page_Load i am written --> Control uc = LoadControl("MyUserControl"); PlaceHolder.Controls.Add(uc); step2: In UserControl there is GridView Control Need to bind the gridview only in "Default.aspx.cs" Can you please help me, how to bind the gridview control of usercontrol which is loaded and need to bind only in Defalut.aspx.cs Thanks in Advance.

    JohnDas

    N A 2 Replies Last reply
    0
    • J Johndas

      Hi All, i am struck in between the logic. My question is i am loading the user control dynamically as follows. step1: --> In Defalut.aspx.cs--> page_Load i am written --> Control uc = LoadControl("MyUserControl"); PlaceHolder.Controls.Add(uc); step2: In UserControl there is GridView Control Need to bind the gridview only in "Default.aspx.cs" Can you please help me, how to bind the gridview control of usercontrol which is loaded and need to bind only in Defalut.aspx.cs Thanks in Advance.

      JohnDas

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Johndas wrote:

      how to bind the gridview control of usercontrol

      The way you normally would, assign the datasource and call DataBind.

      Johndas wrote:

      need to bind only in Defalut.aspx.cs

      Set the data source for the gridview to null in this case.


      only two letters away from being an asset

      1 Reply Last reply
      0
      • J Johndas

        Hi All, i am struck in between the logic. My question is i am loading the user control dynamically as follows. step1: --> In Defalut.aspx.cs--> page_Load i am written --> Control uc = LoadControl("MyUserControl"); PlaceHolder.Controls.Add(uc); step2: In UserControl there is GridView Control Need to bind the gridview only in "Default.aspx.cs" Can you please help me, how to bind the gridview control of usercontrol which is loaded and need to bind only in Defalut.aspx.cs Thanks in Advance.

        JohnDas

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        Make the gridview of the Usercontrol as public, Add

        uc.gridView.DataSource= yourdatasource;
        uc.gridView.DataBind();
        //This is essential, as it is used to render html from datasource.

        Or you can modify the control to handle this itself .. :)

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Microsoft Bing MAP using Javascript
        CLR objects in SQL Server 2005
        Uncommon C# Keywords
        /xml>

        N 1 Reply Last reply
        0
        • A Abhishek Sur

          Make the gridview of the Usercontrol as public, Add

          uc.gridView.DataSource= yourdatasource;
          uc.gridView.DataBind();
          //This is essential, as it is used to render html from datasource.

          Or you can modify the control to handle this itself .. :)

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Microsoft Bing MAP using Javascript
          CLR objects in SQL Server 2005
          Uncommon C# Keywords
          /xml>

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          IMO, a very poor design to directly expose the controls within a user control or server control.


          only two letters away from being an asset

          A 1 Reply Last reply
          0
          • N Not Active

            IMO, a very poor design to directly expose the controls within a user control or server control.


            only two letters away from being an asset

            A Offline
            A Offline
            Abhishek Sur
            wrote on last edited by
            #5

            Ya. Then he can have a property(I thought the user already knows the use of properties ;P ) to expose the gridview... ;)

            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


            My Latest Articles-->** Microsoft Bing MAP using Javascript
            CLR objects in SQL Server 2005
            Uncommon C# Keywords
            /xml>

            N 1 Reply Last reply
            0
            • A Abhishek Sur

              Ya. Then he can have a property(I thought the user already knows the use of properties ;P ) to expose the gridview... ;)

              Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


              My Latest Articles-->** Microsoft Bing MAP using Javascript
              CLR objects in SQL Server 2005
              Uncommon C# Keywords
              /xml>

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              Then why the down vote?


              only two letters away from being an asset

              A 1 Reply Last reply
              0
              • N Not Active

                Then why the down vote?


                only two letters away from being an asset

                A Offline
                A Offline
                Abhishek Sur
                wrote on last edited by
                #7

                Sorry friend... Vote changed. :-D :rose:

                Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                My Latest Articles-->** Microsoft Bing MAP using Javascript
                CLR objects in SQL Server 2005
                Uncommon C# Keywords
                /xml>

                N 1 Reply Last reply
                0
                • A Abhishek Sur

                  Sorry friend... Vote changed. :-D :rose:

                  Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                  My Latest Articles-->** Microsoft Bing MAP using Javascript
                  CLR objects in SQL Server 2005
                  Uncommon C# Keywords
                  /xml>

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  Thanks, but negated by pettiness from MarkyMark1961[^] I assume


                  only two letters away from being an asset

                  C 1 Reply Last reply
                  0
                  • N Not Active

                    Thanks, but negated by pettiness from MarkyMark1961[^] I assume


                    only two letters away from being an asset

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    These downvoters have the opposite effect in the end. I've corrected the 1 votes.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    N 1 Reply Last reply
                    0
                    • C Christian Graus

                      These downvoters have the opposite effect in the end. I've corrected the 1 votes.

                      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                      N Offline
                      N Offline
                      Not Active
                      wrote on last edited by
                      #10

                      Thanks


                      only two letters away from being an asset

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups