|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASP.net - GridViewI have a gridview control bound to a objectdatasource. The primary key column is on the grid but made visible = false. Because the column is invisible I cant get to the cell value when the user presses the edit button on the grid. Code Sub CustomersGridView_RowEditing(ByVal sender As Object, ByVal e As GridViewEditEventArgs) String bedpID = CustomersGridView.Rows(e.NewEditIndex).Cells(1).Text end sub I have set up the grdBedpDetails.DataKeyNames property but this is only useful in the selectedindex event not the RowEditing event CustomersGridView.Rows(e.NewEditIndex).Cells(1).Text return a empty string because the column is invisible. Thanks -- Life in the sun any help Bump...
-- Show quoteHide quoteLife in the sun "WayDownUnder" wrote: > Hello, > I have a gridview control bound to a objectdatasource. > The primary key column is on the grid but made visible = false. > Because the column is invisible I cant get to the cell value when the user > presses > the edit button on the grid. > Code > > Sub CustomersGridView_RowEditing(ByVal sender As Object, ByVal e As > GridViewEditEventArgs) > > > String bedpID = CustomersGridView.Rows(e.NewEditIndex).Cells(1).Text > end sub > > I have set up the grdBedpDetails.DataKeyNames property > but this is only useful in the selectedindex event not the RowEditing event > > CustomersGridView.Rows(e.NewEditIndex).Cells(1).Text return a empty string > because the column is invisible. > > Thanks > > > -- > Life in the sun Hi,
Thank you for posting here! I notice that you have posted the same question in our dotnet.languages.csharp newsgroup, which I have already responded. So please check my answer there and if you need any further assistance on this particular issue, please reply to me in that thread so I can follow up with you in time. For your convenience, I have included my reply as follows: -------------------- You have two options to get the hidden columns' values depending on whether or not the columns belong to the DataKeyNames property of GridView. 1) If the hidden columns are included in DataKeyNames: int id = (int) grdBedpDetails.DataKeys[e.NewEditIndex].Values[0]; 2) If the hidden columns are not included in DataKeyNames: Since hidden columns are not rendered to the client, you need to hide the columns using CSS rule instead of setting its property Visible="false". Below are the detailed steps: a) Create a CSS rule in html header: <style type="text/css"> .hidden { display: none; } </style> b) Hide a column by applying CSS class to its header and item: <asp:BoundField DataField="ID" HeaderStyle-CssClass="hidden" ItemStyle-CssClass="hidden" /> c) Then you can get the ID column text by: String bedpID = grdBedpDetails.Rows[e.NewEditIndex].Cells[1].Text; ---------- Thank you and have a nice day! Regards, Walter Wang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Common VB nomenclature
Thread issue ?? Data in datagridview from a text file Working with multiple displays referencing cells in Excel and finding empty cells Access to Access Database Need I internet programming with Socket? create registry value - bug in VS? ActiveX can't creat object? How to change computer's "Time Zone" from vb.net |
|||||||||||||||||||||||