problem with UpdatePanel in GridView

J

Jeff

hi

asp.net 3.5

I'm wondering if UpdatePanel can work inside a GridView. So I created a
simple test page (below you see a part of the markup of my test page.)...
This GridView contains 2 rows. When I tested this page. Only the content in
the UpdatePanel of last row gets updated.

So I wonder what I do wrong as only the last row get updated... And also I
would like the each UpdatePanel on each row to retrieve data specific for
that row. So I'm not sure how to do that.. I mean what events should I look
into?

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick"
Interval="10000"></asp:Timer>

<asp:GridView ID="gvTest"
DataSourceID="SqlDataSource1"
runat="server" AutoGenerateColumns="false"
OnRowDataBound="gvTest_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Literal ID="Literal1"
runat="server"></asp:Literal>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1"
runat="server">
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="Timer1" EventName="Tick" />
</Triggers>

<ContentTemplate>
<asp:Label ID="Label3" Text="Panel
created" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>


protected void Timer1_Tick(object sender, EventArgs e)
{
Label3.Text = "Refreshed at " + DateTime.Now.ToString();
}
 
G

Gregory A. Beamer

Put the GridView in the UpdatePanel rather than create tons of UpdatePanel
controls on your page (check the HTML produced in the browser to see what I
mean).

This tutorial might give you a head start on your problem:
http://tinyurl.com/86owzo

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 

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

Top