Datakey for Datagrid

Discussion in 'ASP .Net Datagrid Control' started by Kimberly, Jul 18, 2003.

  1. Kimberly

    Kimberly Guest

    Hi - Is it impossible to define multiple datakeys for a datagrid? If
    so - any ideas on how to update a record selected from a datagrid
    using the Edit, Update, Cancel buttons? I can not get past trying to
    define my datakeys. I can define one of the keys but what about the
    other 2?? Here is my code...

    //These fields make up my key

    DateTime Event_start =
    (DateTime)event_grid.DataKeys[e.Item.ItemIndex];
    string plat = (TextBox)e.Item.Cells[1].Controls[0];
    string system = (TextBox)e.Item.Cells[3].Controls[0];

    //get the new values that were entered

    event_text = (TextBox)e.Item.Cells[0].Controls[0];
    Event_start_display = (TextBox)e.Item.Cells[2].Controls[0];
    Notify_start = (TextBox)e.Item.Cells[4].Controls[0];

    string Update_db = "update t_cust_appl_evt set ntfy_strt_dtm
    ='"+Notify_start.Text.Trim()+"'...

    Any help is greatly appreciated.
     
    Kimberly, Jul 18, 2003
    #1
    1. Advertising

  2. Kimberly

    Teemu Keiski Guest

    No,

    you could combine all key fields into one in the SQL query and set this
    combined field to be the data key field. When you need keys, just split them
    up from the combined representation (for example comma-separated)

    --
    Teemu Keiski
    MCP, Designer/Developer
    Mansoft tietotekniikka Oy
    http://www.mansoft.fi

    AspInsiders Member, www.aspinsiders.com
    ASP.NET Forums Moderator, www.asp.net
    AspAlliance Columnist, www.aspalliance.com


    "Kimberly" <> wrote in message
    news:...
    > Hi - Is it impossible to define multiple datakeys for a datagrid? If
    > so - any ideas on how to update a record selected from a datagrid
    > using the Edit, Update, Cancel buttons? I can not get past trying to
    > define my datakeys. I can define one of the keys but what about the
    > other 2?? Here is my code...
    >
    > //These fields make up my key
    >
    > DateTime Event_start =
    > (DateTime)event_grid.DataKeys[e.Item.ItemIndex];
    > string plat = (TextBox)e.Item.Cells[1].Controls[0];
    > string system = (TextBox)e.Item.Cells[3].Controls[0];
    >
    > //get the new values that were entered
    >
    > event_text = (TextBox)e.Item.Cells[0].Controls[0];
    > Event_start_display = (TextBox)e.Item.Cells[2].Controls[0];
    > Notify_start = (TextBox)e.Item.Cells[4].Controls[0];
    >
    > string Update_db = "update t_cust_appl_evt set ntfy_strt_dtm
    > ='"+Notify_start.Text.Trim()+"'...
    >
    > Any help is greatly appreciated.
     
    Teemu Keiski, Jul 19, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Ormaetxe

    Datakey in Datagrid

    J. Ormaetxe, Oct 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    6,668
    Egbert Nierop \(MVP for IIS\)
    Oct 29, 2003
  2. Alex
    Replies:
    2
    Views:
    2,440
    =?Utf-8?B?SG1udA==?=
    Apr 25, 2004
  3. Karl

    Re: DataGrid and DataKey

    Karl, Aug 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    619
    Weston Weems
    Aug 26, 2004
  4. Joel Reinford

    Datagrid selectedindex from datakey value

    Joel Reinford, Oct 5, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    9,815
    S. Justin Gengo
    Oct 5, 2005
  5. Rod
    Replies:
    2
    Views:
    861
Loading...

Share This Page