G
GoogleAccounts
I have a simple DetailsView in ReadOnly mode. I have paging enabled
because I need to show more than one record.
When user clicks next/prev page (PageIndexChanged event) I need to get
the current record ID (that is not one of the displayed fields, so
..Cell(x) won't work).
I expected DetailsView.SelectedValue to do the job but it doesn't (it's
always Nothing).
How can I solve this? My code follows.
1 %@ Page Language="VB" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <script runat="server">
6
7 Protected Sub DetailsView1_PageIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
8 TextBox1.Text = DetailsView1.SelectedValue & ""
9 End Sub
10 </script>
11
12 <html xmlns="http://www.w3.org/1999/xhtml" >
13 <head runat="server">
14 <title>Untitled Page</title>
15 </head>
16 <body>
17 <form id="form1" runat="server">
18 <div>
19 <asp
etailsView ID="DetailsView1" runat="server"
AllowPaging="True" AutoGenerateRows="False"
20 DataKeyNames="DocumentID"
DataSourceID="SqlDataSource1"
21 OnPageIndexChanged="DetailsView1_PageIndexChanged"
DataMember="DefaultView">
22 <Fields>
23 <asp:BoundField DataField="Revision"
HeaderText="Revision" SortExpression="Revision" />
24 <asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
25 </Fields>
26 </asp
etailsView>
27 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
28 SelectCommand="SELECT * FROM
[Documents]"></asp:SqlDataSource>
29 <br />
30 <asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox></div>
31 </form>
32 </body>
33 </html>
because I need to show more than one record.
When user clicks next/prev page (PageIndexChanged event) I need to get
the current record ID (that is not one of the displayed fields, so
..Cell(x) won't work).
I expected DetailsView.SelectedValue to do the job but it doesn't (it's
always Nothing).
How can I solve this? My code follows.
1 %@ Page Language="VB" %>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <script runat="server">
6
7 Protected Sub DetailsView1_PageIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs)
8 TextBox1.Text = DetailsView1.SelectedValue & ""
9 End Sub
10 </script>
11
12 <html xmlns="http://www.w3.org/1999/xhtml" >
13 <head runat="server">
14 <title>Untitled Page</title>
15 </head>
16 <body>
17 <form id="form1" runat="server">
18 <div>
19 <asp
AllowPaging="True" AutoGenerateRows="False"
20 DataKeyNames="DocumentID"
DataSourceID="SqlDataSource1"
21 OnPageIndexChanged="DetailsView1_PageIndexChanged"
DataMember="DefaultView">
22 <Fields>
23 <asp:BoundField DataField="Revision"
HeaderText="Revision" SortExpression="Revision" />
24 <asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
25 </Fields>
26 </asp
27 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
28 SelectCommand="SELECT * FROM
[Documents]"></asp:SqlDataSource>
29 <br />
30 <asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox></div>
31 </form>
32 </body>
33 </html>