J jaYPee Mar 1, 2004 #1 i'm wondering how can i get the value of primary key in datagrid. thanks in advance
E Ed Bick Mar 1, 2004 #2 jaYPee said: i'm wondering how can i get the value of primary key in datagrid. Click to expand... Do you mean to have it present so that you can click on a row and retrieve the value, but not see the pk in the grid? If yes, you can include the column in your data set and set the width of the column to 0. Then, in your grids Click event, do something like this. Dim dc As DataGridCell = MyGrid.CurrentCell 'This will be set to column 0 of the row you selected. You can change that to whatever column you like Dim intID As Integer = MyGrid.Item(dc) Hope that helps.
jaYPee said: i'm wondering how can i get the value of primary key in datagrid. Click to expand... Do you mean to have it present so that you can click on a row and retrieve the value, but not see the pk in the grid? If yes, you can include the column in your data set and set the width of the column to 0. Then, in your grids Click event, do something like this. Dim dc As DataGridCell = MyGrid.CurrentCell 'This will be set to column 0 of the row you selected. You can change that to whatever column you like Dim intID As Integer = MyGrid.Item(dc) Hope that helps.
S Sjaakie Helderhorst Mar 1, 2004 #3 Make the first column of you datagrid readonly and invisible: <asp:BoundColumn Visible="False" DataField="[your uid]" ReadOnly="True" HeaderText="uid"></asp:BoundColumn> In your updatecommand refer to it as uid = '" & e.Item.Cells(0).Text & "' Hope this helps. Regards!
Make the first column of you datagrid readonly and invisible: <asp:BoundColumn Visible="False" DataField="[your uid]" ReadOnly="True" HeaderText="uid"></asp:BoundColumn> In your updatecommand refer to it as uid = '" & e.Item.Cells(0).Text & "' Hope this helps. Regards!