locked
Columns in a Custom GridView RRS feed

  • Question

  • User503704278 posted

    Hello All,

    I am writing my first custom control which is a custom grid.  I have extended the GridView class.  I am adding some columns (4 columns) which are visible to users.  I also have some data (IDs for rows) which I don't want to display to users but want to hold along with each row.  For this column, I am creating a TemplateField and adding a invisible text box to it to hold IDs.  When the grid is loaded first time, it has 5 columns (4 visible + 1 invisible).  But when I click on "Delete" or "Edit" link on grid, I get only the first 4 columns and the ID which I had added earlier is lost.  I am adding all the columns in only one place.  Can somebody please suggest any solution.

    Regards,

    crbherde
     

    Monday, April 28, 2008 7:14 AM

Answers

  • User874596136 posted

    Why you don't use GridView's DataKeyNames and DataKeys properties for storing ids? They should be used exactly in such cases.

    You can even define multiple keys. You can access keys in the same way as accessing rows, that is through GridView.DataKeys[rowIndex] accessor.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 28, 2008 1:56 PM

All replies

  • User874596136 posted

    Why you don't use GridView's DataKeyNames and DataKeys properties for storing ids? They should be used exactly in such cases.

    You can even define multiple keys. You can access keys in the same way as accessing rows, that is through GridView.DataKeys[rowIndex] accessor.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 28, 2008 1:56 PM
  • User503704278 posted

    Great!!  Thank you very much.  I just realised that I wasted my weekend creating problems for myself and then sorting them.

     

    Tuesday, April 29, 2008 1:55 AM