javascript to bind data to gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anudu
    New Member
    • Oct 2007
    • 31

    javascript to bind data to gridview

    hi all programming experts,

    I am developing a system using asp.net(c#) , ajax and javascripts. I want to bind a dataset to a gridview using a javascrip function. the javascript function is written in a different .js file and linked to the aspx page. i am calling that function in "onclientcl ick" method in a button because i want to stop post back. i am not using an update pannel. i am caaling code behind function to get the required dataset.i have successfully taken the dataset to the function but the problem is how to set the data source & call the databind method of a gridview in javascript?

    Thanx
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by anudu
    hi all programming experts,

    I am developing a system using asp.net(c#) , ajax and javascripts. I want to bind a dataset to a gridview using a javascrip function. the javascript function is written in a different .js file and linked to the aspx page. i am calling that function in "onclientcl ick" method in a button because i want to stop post back. i am not using an update pannel. i am caaling code behind function to get the required dataset.i have successfully taken the dataset to the function but the problem is how to set the data source & call the databind method of a gridview in javascript?

    Thanx
    Post the code you tried so far :-)

    Debasis Jana

    Comment

    • anudu
      New Member
      • Oct 2007
      • 31

      #3
      Originally posted by dmjpro
      Post the code you tried so far :-)

      Debasis Jana
      this is the jscript function i am trying

      [CODE=javascript]function BindData()
      {
      alert('in');
      var retDset=primary Inquries.TestDa taSet(); //get dataset from codeBehind

      alert(retDset.v alue.Tables[0].Rows.length); // to check the nimber of rows

      // dataset is received correctly
      document.getEle mentById("GridV iew1").DataSour ce=retDset; //?problem
      document.getEle mentById("GridV iew1").Bind(); // ?problem. how to bind the received dataset to the grid view
      return false;


      }//end BindData[/CODE]
      Last edited by acoder; Oct 31 '07, 08:12 AM. Reason: Added code tags

      Comment

      • anudu
        New Member
        • Oct 2007
        • 31

        #4
        binding data to a datagridview in asp.net with javascript

        hi all programming experts,

        I am developing a system using asp.net(c#) , ajax and javascripts. I want to bind a dataset to a gridview using a javascrip function. the javascript function is written in a different .js file and linked to the aspx page. i am calling that function in "onclientcl ick" method in a button because i want to stop post back. i am not using an update pannel. i am caaling code behind function to get the required dataset.i have successfully taken the dataset to the function but the problem is how to set the data source & call the databind method of a gridview in javascript?

        Thanx


        this is the jscript function i am trying

        [CODE=asp]function BindData()
        {
        alert('in');
        var retDset=primary Inquries.TestDa taSet(); //get dataset from codeBehind

        alert(retDset.v alue.Tables[0].Rows.length); // to check the nimber of rows

        // dataset is received correctly
        document.getEle mentById("GridV iew1").DataSour ce=retDset; //?problem
        document.getEle mentById("GridV iew1").Bind(); // ?problem. how to bind the received dataset to the grid view
        return false;


        }//end BindData[/CODE]
        Last edited by gits; Oct 12 '07, 09:09 AM. Reason: added code tags

        Comment

        • pronerd
          Recognized Expert Contributor
          • Nov 2006
          • 392

          #5
          It looks like their maybe some confusion between the lines of JavaScript and ASP.

          JavaScript is clients side, it only runs on the browser, so it has no ablity to work with ASP.NET ojects like DataSets or GridViews. Browser based JavaScript can only access HTML elements in that browser instance.

          It looks like you may need to post your questions in the ASP support forum.

          Originally posted by anudu
          hi all programming experts,

          I am developing a system using asp.net(c#) , ajax and javascripts. I want to bind a dataset to a gridview using a javascrip function. the javascript function is written in a different .js file and linked to the aspx page. i am calling that function in "onclientcl ick" method in a button because i want to stop post back. i am not using an update pannel. i am caaling code behind function to get the required dataset.i have successfully taken the dataset to the function but the problem is how to set the data source & call the databind method of a gridview in javascript?

          Thanx


          this is the jscript function i am trying

          [CODE=asp]function BindData()
          {
          alert('in');
          var retDset=primary Inquries.TestDa taSet(); //get dataset from codeBehind

          alert(retDset.v alue.Tables[0].Rows.length); // to check the nimber of rows

          // dataset is received correctly
          document.getEle mentById("GridV iew1").DataSour ce=retDset; //?problem
          document.getEle mentById("GridV iew1").Bind(); // ?problem. how to bind the received dataset to the grid view
          return false;


          }//end BindData[/CODE]

          Comment

          • krispaks
            New Member
            • Oct 2007
            • 3

            #6
            i also have the same situation... i hope more can help here... tnx...

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Welcome to TSDN!
              Originally posted by krispaks
              i also have the same situation... i hope more can help here... tnx...
              Can you post your code? Also, explain the format of the data.

              Comment

              • krispaks
                New Member
                • Oct 2007
                • 3

                #8
                i still dont have any code... im quite new to ajax... im still thinking if its possible... my setup is like this:

                i have this calender extender setup... then on its OnClientDateSel ectionChanged i added a javascript... that would get the date and then using that date i will use a web service so i could get data from my database and pass it to the bindingsource.. . is this possible???

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  It should be possible. See this AJAX example to get you started.

                  Comment

                  • fjlewis
                    New Member
                    • Apr 2009
                    • 1

                    #10
                    You must be looking for a data aware javascript components.

                    Try open source project messi.

                    Messi is a data aware component lib extended from ext-js lib with GNU licence, including group header grid, scrollable dataset, dataware widges, auto lookup combobox. It aims to minimize the develop cost of web database application.

                    Data aware widges can be auto linked to grid via a scrollable dataset. Form widges's changed value will be auto updated to dataset' last record after dataset scrolled. Also, the values of record at the new position of dataset will auto be refected to the widges.

                    The project is hosted on sourceforce.

                    Comment

                    Working...