0
我是一個嘗試在gridview中檢索所選行的值的新手vb程序員。還沒有能夠到目前爲止。我搜索了所有的論壇,沒有任何答案對我有用。 這裏是代碼的HTML部分:在gridview中從選定行中獲取值
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
ForeColor="#333333" GridLines="None" Width="1032px"
EnableModelValidation="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="Date" >
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" onclick ="LinkButton1_Click"
CommandName="DrillTP" Text='<%#Eval("transit_date")%>'> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="transit_date" HeaderText="Date" Visible="false" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="day_type" HeaderText="DayType" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="current_route_id" HeaderText="Line" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="bs_lname" HeaderText="Location" >
<HeaderStyle HorizontalAlign="Left" />
</asp:BoundField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
在Visual Basic
,我試圖捕捉到選定的日期,然後放置一個標籤,該標籤信息,但一直沒能還。有什麼建議麼?我有這個:
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs) '(sender As Object, e As DataGridCommandEventArgs)
Label1.Text = GridView1.SelectedRow.DataItem
End Sub
顯然,我失去了一些東西,任何幫助表示讚賞。另外,請讓我知道我是否可以更有效地發佈此問題。 謝謝!!
'selectedrows'在這一點上不是一個選項,但'selectedrow'是。我嘗試過,但沒有奏效 – MM3000