Set DetailsView as selected row of GridView
Posted
by Nix
on Stack Overflow
See other posts from Stack Overflow
or by Nix
Published on 2010-05-10T17:22:07Z
Indexed on
2010/05/10
17:24 UTC
Read the original article
Hit count: 207
ASP.NET
|objectdatasource
I am afraid this is a brain fart question. But I have searched around and have not been able to find the answer.
I am creating a GridView/DetailsView page. I have a grid that displays a bunch of rows, when a row is selected it uses a DetailsView to allow for Insert/Update.
My question is what is the best way to link these? I do not want to reach out to the web service again, all the data i need is in the selected grid view row. I basically have 2 separate data sources that share the same "DataObjectTypeName", the first data source retrieves the data, and the other to do the CRUD.
What is the best way to transfer the Selected Grid View row to the Details View? Am I going to have to manualy handle the Insert/Update events and call the data source myself?
<asp:GridView ID="gvDetails" runat="server" DataKeyNames="ID, Code"
DataSourceID="odsSearchData" >
<Columns>
<asp:BoundField DataField="RowA" HeaderText="A" SortExpression="RowA" />
<asp:BoundField DataField="RowB" HeaderText="B" SortExpression="RowB" />
<asp:BoundField DataField="RowC" HeaderText="C" SortExpression="RowC" />
....Code...
<asp:DetailsView ID="dvDetails" runat="server" DataKeyNames="ID, Code"
DataSourceID="odsCRUD" GridLines="None" DefaultMode="Edit" AutoGenerateRows="false"
Visible="false" Width="100%">
<Fields>
<asp:BoundField DataField="RowA" HeaderText="A" SortExpression="RowA" />
<asp:BoundField DataField="RowB" HeaderText="B" SortExpression="RowB" />
<asp:BoundField DataField="RowC" HeaderText="C" SortExpression="RowC" />
...
© Stack Overflow or respective owner