Datagrid - can that be refreshed via client side javascript?

Discussion in 'ASP .Net Web Controls' started by James Radke, Nov 11, 2003.

  1. James Radke

    James Radke Guest

    Hello,

    Through this forum I have found out that you can refresh most web page
    controls via javascript.

    That made me wonder if there is a way to refresh (.i.e. rebind) a bound
    datagrid via combination of webservice calls and javascript functions so
    that a complete page roundtrip is not necessary to refresh only a datagrid
    within the page.

    Does anyone know if this is possible, and if so, how one could go about
    doing it?

    Thanks!

    Jim
     
    James Radke, Nov 11, 2003
    #1
    1. Advertising

  2. Hi James,

    Thank you for posting to the MSDN newsgroups.

    I am interested in this issue and researching it now. More time is needed.
    I will update you as soon as possible.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Nov 13, 2003
    #2
    1. Advertising

  3. James Radke

    James Radke Guest

    Jacob,

    Thanks! Let me know what you find out..... If there was a way to do that,
    it would be very nice.....

    Jim

    "Jacob Yang [MSFT]" <> wrote in message
    news:k$...
    > Hi James,
    >
    > Thank you for posting to the MSDN newsgroups.
    >
    > I am interested in this issue and researching it now. More time is needed.
    > I will update you as soon as possible.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
     
    James Radke, Nov 13, 2003
    #3
  4. Hi James,

    I have done a lot of research regarding this issue. Based on my research
    and experience, I don't think that we can refresh/rebind the datagrid web
    control via the client script.

    The reason is that the datagrid web control is a server side control. In
    the client side, what we get is a HTML table. Please test the following
    simple sample on your side.
    ----------------------------------------------------------------------------
    ------------
    <%@ Page Language="VB" AutoEventWireup="True" %>
    <%@ Import Namespace="System.Data" %>

    <html>
    <script language="VB" runat="server">
    Function CreateDataSource() As ICollection
    Dim dt As New DataTable()
    Dim dr As DataRow

    dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
    dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
    dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))

    Dim i As Integer
    For i = 0 To 8
    dr = dt.NewRow()

    dr(0) = i
    dr(1) = "Item " + i.ToString()
    dr(2) = 1.23 *(i + 1)

    dt.Rows.Add(dr)
    Next i

    Dim dv As New DataView(dt)
    Return dv
    End Function 'CreateDataSource


    Sub Page_Load(sender As Object, e As EventArgs)

    If Not IsPostBack Then
    ' Load this data only once.
    ItemsGrid.DataSource = CreateDataSource()
    ItemsGrid.DataBind()
    End If
    End Sub 'Page_Load

    </script>

    <body>

    <form runat=server>

    <h3>DataGrid Example</h3>

    <b>Product List</b>

    <asp:DataGrid id="ItemsGrid"
    BorderColor="black"
    BorderWidth="1"
    CellPadding="3"
    AutoGenerateColumns="true"
    runat="server">

    <HeaderStyle BackColor="#00aaaa">
    </HeaderStyle>

    </asp:DataGrid>

    </form>

    </body>
    </html>
    ---------------------------------------------------------------------

    On the client side, please access the above web page and select
    IE->View->Source. We can see the following HTML code.
    -------------------------------------------------------
    ...
    <table cellspacing="0" cellpadding="3" rules="all" bordercolor="Black"
    border="1" id="ItemsGrid"
    style="border-color:Black;border-width:1px;border-style:solid;border-collaps
    e:collapse;">
    <tr style="background-color:#00AAAA;">
    <td>IntegerValue</td><td>StringValue</td><td>CurrencyValue</td>
    </tr><tr>
    <td>0</td><td>Item 0</td><td>1.23</td>
    </tr><tr>
    <td>1</td><td>Item 1</td><td>2.46</td>
    </tr><tr>
    <td>2</td><td>Item 2</td><td>3.69</td>
    </tr><tr>
    <td>3</td><td>Item 3</td><td>4.92</td>
    </tr><tr>
    <td>4</td><td>Item 4</td><td>6.15</td>
    </tr><tr>
    <td>5</td><td>Item 5</td><td>7.38</td>
    </tr><tr>
    <td>6</td><td>Item 6</td><td>8.61</td>
    </tr><tr>
    <td>7</td><td>Item 7</td><td>9.84</td>
    </tr><tr>
    <td>8</td><td>Item 8</td><td>11.07</td>
    </tr>
    </table>
    ...
    ---------------------------------------------------------------

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jacob Yang [MSFT], Nov 14, 2003
    #4
  5. James Radke

    James Radke Guest

    Jacob,

    Thats what I thought, but I was hoping there was something I missed!

    Thanks for looking into it in detail though!

    Jim

    "Jacob Yang [MSFT]" <> wrote in message
    news:...
    > Hi James,
    >
    > I have done a lot of research regarding this issue. Based on my research
    > and experience, I don't think that we can refresh/rebind the datagrid web
    > control via the client script.
    >
    > The reason is that the datagrid web control is a server side control. In
    > the client side, what we get is a HTML table. Please test the following
    > simple sample on your side.
    > --------------------------------------------------------------------------

    --
    > ------------
    > <%@ Page Language="VB" AutoEventWireup="True" %>
    > <%@ Import Namespace="System.Data" %>
    >
    > <html>
    > <script language="VB" runat="server">
    > Function CreateDataSource() As ICollection
    > Dim dt As New DataTable()
    > Dim dr As DataRow
    >
    > dt.Columns.Add(New DataColumn("IntegerValue", GetType(Int32)))
    > dt.Columns.Add(New DataColumn("StringValue", GetType(String)))
    > dt.Columns.Add(New DataColumn("CurrencyValue", GetType(Double)))
    >
    > Dim i As Integer
    > For i = 0 To 8
    > dr = dt.NewRow()
    >
    > dr(0) = i
    > dr(1) = "Item " + i.ToString()
    > dr(2) = 1.23 *(i + 1)
    >
    > dt.Rows.Add(dr)
    > Next i
    >
    > Dim dv As New DataView(dt)
    > Return dv
    > End Function 'CreateDataSource
    >
    >
    > Sub Page_Load(sender As Object, e As EventArgs)
    >
    > If Not IsPostBack Then
    > ' Load this data only once.
    > ItemsGrid.DataSource = CreateDataSource()
    > ItemsGrid.DataBind()
    > End If
    > End Sub 'Page_Load
    >
    > </script>
    >
    > <body>
    >
    > <form runat=server>
    >
    > <h3>DataGrid Example</h3>
    >
    > <b>Product List</b>
    >
    > <asp:DataGrid id="ItemsGrid"
    > BorderColor="black"
    > BorderWidth="1"
    > CellPadding="3"
    > AutoGenerateColumns="true"
    > runat="server">
    >
    > <HeaderStyle BackColor="#00aaaa">
    > </HeaderStyle>
    >
    > </asp:DataGrid>
    >
    > </form>
    >
    > </body>
    > </html>
    > ---------------------------------------------------------------------
    >
    > On the client side, please access the above web page and select
    > IE->View->Source. We can see the following HTML code.
    > -------------------------------------------------------
    > ..
    > <table cellspacing="0" cellpadding="3" rules="all" bordercolor="Black"
    > border="1" id="ItemsGrid"
    >

    style="border-color:Black;border-width:1px;border-style:solid;border-collaps
    > e:collapse;">
    > <tr style="background-color:#00AAAA;">
    > <td>IntegerValue</td><td>StringValue</td><td>CurrencyValue</td>
    > </tr><tr>
    > <td>0</td><td>Item 0</td><td>1.23</td>
    > </tr><tr>
    > <td>1</td><td>Item 1</td><td>2.46</td>
    > </tr><tr>
    > <td>2</td><td>Item 2</td><td>3.69</td>
    > </tr><tr>
    > <td>3</td><td>Item 3</td><td>4.92</td>
    > </tr><tr>
    > <td>4</td><td>Item 4</td><td>6.15</td>
    > </tr><tr>
    > <td>5</td><td>Item 5</td><td>7.38</td>
    > </tr><tr>
    > <td>6</td><td>Item 6</td><td>8.61</td>
    > </tr><tr>
    > <td>7</td><td>Item 7</td><td>9.84</td>
    > </tr><tr>
    > <td>8</td><td>Item 8</td><td>11.07</td>
    > </tr>
    > </table>
    > ..
    > ---------------------------------------------------------------
    >
    > If I have misunderstood your concern, please feel free to let me know.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
     
    James Radke, Nov 14, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    2
    Views:
    1,054
    Steven Cheng[MSFT]
    Jul 16, 2004
  2. Rob
    Replies:
    7
    Views:
    6,209
    Patrick.O.Ige
    Dec 7, 2005
  3. Joana
    Replies:
    1
    Views:
    351
    Joana
    Dec 7, 2003
  4. Boss302
    Replies:
    0
    Views:
    1,086
    Boss302
    Nov 21, 2006
  5. R.D.CHETTY

    Pages are not refreshed on client machines

    R.D.CHETTY, Jun 22, 2004, in forum: ASP General
    Replies:
    1
    Views:
    105
    Aaron [SQL Server MVP]
    Jun 22, 2004
Loading...

Share This Page