Datagrid - can that be refreshed via client side javascript?

J

James Radke

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
 
J

Jacob Yang [MSFT]

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.
 
J

James Radke

Jacob,

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

Jim
 
J

Jacob Yang [MSFT]

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.
 
J

James Radke

Jacob,

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

Thanks for looking into it in detail though!

Jim
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top