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. Prob with delegates

Prob with delegates

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-netdatabasehelp
7 Posts 2 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.
  • A Offline
    A Offline
    amalatsliit
    wrote on last edited by
    #1

    In my Asp.net application i have divided my web form in to 2 colums.top frame will load a page and it has datagrid control.bottom one have a dropdownlist with few codes. iwant to fill my data grid accourding to the change of my DDL. therefore i create a delegate in my top.aspx form and a function to fill data from DB.and i call above function when change the SelectedIndex of my DDL.now my parameter values passed to top.aspx page but can't fill my DG. it gives error called object reference not set..... how can i fill my DG from another page. note:Also these two pages are in two diff namespace.

    M 1 Reply Last reply
    0
    • A amalatsliit

      In my Asp.net application i have divided my web form in to 2 colums.top frame will load a page and it has datagrid control.bottom one have a dropdownlist with few codes. iwant to fill my data grid accourding to the change of my DDL. therefore i create a delegate in my top.aspx form and a function to fill data from DB.and i call above function when change the SelectedIndex of my DDL.now my parameter values passed to top.aspx page but can't fill my DG. it gives error called object reference not set..... how can i fill my DG from another page. note:Also these two pages are in two diff namespace.

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Do you have to use frames? You may find it easier when dealing with postbacks to the same page not to use frames. If you do have to use frames, I think you may need to handle this a little differently: in top.aspx, when you get a postback with the new SelectedIndex, you might do a Response.Redirect() to a URL that points to the outer frameset page, passing along the new index as a querystring parameter. Use server-side code to pass the querystring parameter from the top page to each FRAME page, and within the FRAME pages, test for the existence of this query-string parameter and respond accordingly (e.g. populate the datagrid). Here are three sample files that show what I mean. file: "framesetWithParams.aspx"

      <%@ Page Language="C#" %>
      <script runat="server">

      void Page\_Load(object o, EventArgs e)
      {
          // templates for the src attributes of the top & dg frames
          string frameTop = "framesetWithParams\_top.aspx?index={0}";
          string frameDg  = "framesetWithParams\_dg.aspx?index={0}";
          
          // retrieve the querystring "index" value
          string index = Request.QueryString\["index"\];
          
          // set the "src" attributes for each frame accordingly
          top.Attributes\["src"\] = string.Format(frameTop, index);
          dg.Attributes\["src"\] = string.Format(frameDg, index);
      }
      

      </script>

      <html>
      <head>
      <title></title>
      <frameset rows="30%,70%">
      <frame name='top' id='top' runat='server' />
      <frame name='dg' id='dg' runat='server' />
      </frameset>
      </head>
      <body />
      </html>

      file: "framesetWithParams_top.aspx" (note the use of the <base target=_parent> tag in the <head>... this allows the postback from the dropdown selection to refresh the entire page)

      <%@ Page Language="C#" %>

      <script runat="server">

      void Page_Load(object o, EventArgs e)
      {
      // look for the index code in the querystring
      // (but only the first time; we won't do
      // this on a postback)
      if (!IsPostBack)
      {
      string sCode = Request.QueryString["index"];
      dd.SelectedValue = sCode;
      }
      }

      void HandleSelectedIndexChanged(object o, EventArgs e)
      {
      // on a postback, redirect to the outer frameset page
      // with the selected index
      Response.Redirect("framesetWithParams.aspx?index="

      A 1 Reply Last reply
      0
      • M Mike Ellison

        Do you have to use frames? You may find it easier when dealing with postbacks to the same page not to use frames. If you do have to use frames, I think you may need to handle this a little differently: in top.aspx, when you get a postback with the new SelectedIndex, you might do a Response.Redirect() to a URL that points to the outer frameset page, passing along the new index as a querystring parameter. Use server-side code to pass the querystring parameter from the top page to each FRAME page, and within the FRAME pages, test for the existence of this query-string parameter and respond accordingly (e.g. populate the datagrid). Here are three sample files that show what I mean. file: "framesetWithParams.aspx"

        <%@ Page Language="C#" %>
        <script runat="server">

        void Page\_Load(object o, EventArgs e)
        {
            // templates for the src attributes of the top & dg frames
            string frameTop = "framesetWithParams\_top.aspx?index={0}";
            string frameDg  = "framesetWithParams\_dg.aspx?index={0}";
            
            // retrieve the querystring "index" value
            string index = Request.QueryString\["index"\];
            
            // set the "src" attributes for each frame accordingly
            top.Attributes\["src"\] = string.Format(frameTop, index);
            dg.Attributes\["src"\] = string.Format(frameDg, index);
        }
        

        </script>

        <html>
        <head>
        <title></title>
        <frameset rows="30%,70%">
        <frame name='top' id='top' runat='server' />
        <frame name='dg' id='dg' runat='server' />
        </frameset>
        </head>
        <body />
        </html>

        file: "framesetWithParams_top.aspx" (note the use of the <base target=_parent> tag in the <head>... this allows the postback from the dropdown selection to refresh the entire page)

        <%@ Page Language="C#" %>

        <script runat="server">

        void Page_Load(object o, EventArgs e)
        {
        // look for the index code in the querystring
        // (but only the first time; we won't do
        // this on a postback)
        if (!IsPostBack)
        {
        string sCode = Request.QueryString["index"];
        dd.SelectedValue = sCode;
        }
        }

        void HandleSelectedIndexChanged(object o, EventArgs e)
        {
        // on a postback, redirect to the outer frameset page
        // with the selected index
        Response.Redirect("framesetWithParams.aspx?index="

        A Offline
        A Offline
        amalatsliit
        wrote on last edited by
        #3

        Hello mike, Thank you very much for your answeer.but i have done this by using query string.what i want is to implement common data fill page to all other web ages of my application. you know we can add datagrid individualy by page by page and fill out accourding to parameter fields which we send. In my new web application most of pages has to display entered data from that page.so i want to send these request to one page and fill the DG.also after when user select the griddata,i want to fill out data entry form agin. like :- for the modification.... so this my issue.how can i do this. thankx amal

        M 1 Reply Last reply
        0
        • A amalatsliit

          Hello mike, Thank you very much for your answeer.but i have done this by using query string.what i want is to implement common data fill page to all other web ages of my application. you know we can add datagrid individualy by page by page and fill out accourding to parameter fields which we send. In my new web application most of pages has to display entered data from that page.so i want to send these request to one page and fill the DG.also after when user select the griddata,i want to fill out data entry form agin. like :- for the modification.... so this my issue.how can i do this. thankx amal

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          Build a data tier for your application - it could be as simple as a single class with some static methods for retrieving data from the database, and returning DataTables to the web front-end. Put DataGrid controls on each page necessary, and in each respective Page_Load event, execute the method from your data tier that returns the appropriate DataTable.

          A 1 Reply Last reply
          0
          • M Mike Ellison

            Build a data tier for your application - it could be as simple as a single class with some static methods for retrieving data from the database, and returning DataTables to the web front-end. Put DataGrid controls on each page necessary, and in each respective Page_Load event, execute the method from your data tier that returns the appropriate DataTable.

            A Offline
            A Offline
            amalatsliit
            wrote on last edited by
            #5

            Dear Mike, Can you please provide me a sample code to do above task.it will more help full for me to complete my task. Thankx Amal

            M 1 Reply Last reply
            0
            • A amalatsliit

              Dear Mike, Can you please provide me a sample code to do above task.it will more help full for me to complete my task. Thankx Amal

              M Offline
              M Offline
              Mike Ellison
              wrote on last edited by
              #6

              class MyDataTier
              {
              public static DataTable GetSomeData()
              {
              // .. do whatever is necessary to get a dataset or datatable
              // .. e.g. execute a Select command against a database...
              // .. or read in an Xml data document...
              // .. whatever you need ..
              // .. in the end, return the DataSet, or DataTable, or XmlDocument,
              // .. or whatever makes sense for your application

              return myDataTable;
              

              }
              }

              Then in your ASP.NET web pages you could call the static data tier functions to retrieve the data you need:

              void Page_Load(object o, EventArgs e)
              {
              if (!IsPostBack)
              {
              this.myDataGrid.DataSource = MyDataTier.GetSomeData();
              this.myDataGrid.DataBind();
              }
              }

              A 1 Reply Last reply
              0
              • M Mike Ellison

                class MyDataTier
                {
                public static DataTable GetSomeData()
                {
                // .. do whatever is necessary to get a dataset or datatable
                // .. e.g. execute a Select command against a database...
                // .. or read in an Xml data document...
                // .. whatever you need ..
                // .. in the end, return the DataSet, or DataTable, or XmlDocument,
                // .. or whatever makes sense for your application

                return myDataTable;
                

                }
                }

                Then in your ASP.NET web pages you could call the static data tier functions to retrieve the data you need:

                void Page_Load(object o, EventArgs e)
                {
                if (!IsPostBack)
                {
                this.myDataGrid.DataSource = MyDataTier.GetSomeData();
                this.myDataGrid.DataBind();
                }
                }

                A Offline
                A Offline
                amalatsliit
                wrote on last edited by
                #7

                Dear Mike, Thanx for the reply.any way what i want is to create common web page to display all the nesessary data request from other pages.not to create a common function and call it on other pages. i just want to create common data view page for other child pages.so when the user select the filling criteria from child page the top.aspx page have to display the correct data. e.g : say user going to modify the project details.but before that he wants to view entered project details.when he click the button which is in bottom.aspx my common data fill page that is top.aspx should fill out all entered project details. at the movement i use querystring for this.but i think it's not practical for this.. as a another solution i can do this by creating user control also.but i just want to do that another way. Thanx

                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