|
-
November 12th, 2010, 07:00 AM
#1
Get the ID of a Selected row in a Gridview
Good Day All
I have a Grid defined like this
Code:
<asp:GridView ID="GrdOrdersinProcess" runat="server"
AutoGenerateColumns="False" BackColor="White" BorderColor="#3366CC"
BorderStyle="None" BorderWidth="1px" DataKeyNames="OrderID" CellPadding="4"
DataSourceID="SqlDataSource1"
>
<RowStyle BackColor="White" ForeColor="#003399" />
<Columns>
<asp:TemplateField HeaderText="Order No">
<ItemTemplate>
<asp:Label ID="lblOrderID" runat="server" Text='<%# Eval("OrderID")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Amount">
<ItemTemplate>
<asp:Label ID="lblOrderAmount" runat="server" Text='<%# Eval("OrderAmount")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Order Date">
<ItemTemplate>
<asp:Label ID="lblOrderDateTime" runat="server"
Text='<%# Eval("OrderDateTime")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbkProcess" runat="server" OnClick="lbkProcess_Click"
Text="Process">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
</asp:GridView>
and now as you can see i have a link Button and i have its handler. Before i used to have a Check box and i could find with row has been selected, but now my style is different , i want to get value of "lblOrderID" for the selected record. I dont use a Checkbox to get the selected item because i dont allow multi select into functionality.
How can i get that on the server or client side.
Thanks
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|