To get the Id from a Datagrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: To get the Id from a Datagrid

  1. #1
    Join Date
    Aug 2007
    Location
    London
    Posts
    73

    To get the Id from a Datagrid

    I have some textboxes and dropdownlist where we have to enter data and then
    I have a datagrid in which i have some columns like..
    The first field is a Checkbox column.

    for binding datagrid. i am giving the query like

    select name,address,phone from table1.

    Checkbox Name address Phone

    and at last i have button. So when we click that button, i have to insert some values into a table Table2. The values that r inserting into Table2 are from the controls ouside the grid and One field is the ID, that i have to get from datagrid.

    How to get the corresponding ID , when the checkbox is clicked???

    please help me.....itx urgent

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Change your query to include the ID for each row:

    SELECT id, name, address, phone FROM table1

    Add an invisible BoundColumn to your DataGrid to contain the ID:

    <asp:BoundColumn DataField="ID" Visible="False" />

    Now you may read the ID from the DataGrid as you would any other column.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2007
    Location
    London
    Posts
    73
    at last i did like that only...i thought there will be some other solution for this...

    Anyway Thanks....

Similar Threads

  1. Replies: 7
    Last Post: 07-09-2006, 02:56 AM
  2. Replies: 0
    Last Post: 09-02-2005, 08:28 PM
  3. Replies: 0
    Last Post: 06-05-2003, 10:30 PM
  4. Is there guidelines for proper use of DataGrid
    By Thomas Eyde in forum .NET
    Replies: 8
    Last Post: 08-01-2002, 07:43 PM
  5. Threading and the .NET Datagrid
    By McCleud in forum .NET
    Replies: 2
    Last Post: 08-01-2002, 11:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center