Is it possible to update a detailsview with a gridview in Atlas?

N

needin4mation

Hi, I have a gridview and a detailsview. Is it possible to select a
row in the gridview, not have a postback, and instead have a
detailsview populate based upon the gridview - in Atlas, no postbacks?

Thanks.
 
V

Vlad Iliescu

You could add an UpdatePanel, put the DetailsView in its
ContentTemplate, add an event trigger for the gridview control on
SelectedIndexChanged, and rebind the DetailsView serverside.

Something like:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
AutoGenerateSelectButton="True"
DataKeyNames="ProductID" DataSourceID="SqlDataSource1"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="ProductID"
HeaderText="ProductID" InsertVisible="False"
ReadOnly="True" SortExpression="ProductID" />

</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID] FROM [Alphabetical list
of products]">
</asp:SqlDataSource>
<br />
<br />

<atlas:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Label ID="Label3" runat="server"
Text="Label"></asp:Label>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="GridView1"
EventName="SelectedIndexChanged" />
</Triggers>
</atlas:UpdatePanel>
---
protected void GridView1_SelectedIndexChanged(object sender, EventArgs
e)
{
Label3.Text =
GridView1.SelectedDataKey.Values["ProductID"].ToString();
}
 

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

No members online now.

Forum statistics

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

Latest Threads

Top