How to get Radgrid column item text on SelectedIndexChanged

5 posts, 0 answers
  1. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 15 Jul 2010 Link to this post

    I know

    rg.SelectedItems[0].OwnerTableView.DataKeyValues[rgScheduleList.SelectedItems[0].ItemIndex][

    "SCHEDULE_ID"]

     

     will get the value for the datakey on the grid, how about none data key item text? like name field on the grid?

    Thanks!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jul 2010 Link to this post

    Hi Jessie,


    You can easily achieve this by using the ColumnUniqueName.

    C#:
    protected void Button1_Click(object sender, EventArgs e)
    {
        GridDataItem gridItem = (GridDataItem)RadGrid1.SelectedItems[0];
        string name = gridItem["CompanyName"].Text;  // Get the cell value
     
        string dataKey = gridItem.GetDataKeyValue("CustomerID").ToString(); // Get the datakeyvalue
    }



    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 16 Jul 2010 Link to this post

    Hello Jessie,

    In addition, you can use the GridDataItem object's ExtractValues() method passing to it a hash table. The latter will be populated will the key-value pairs for your columns:

    protected void Button1_Click(object sender, EventArgs e)
    {
        GridDataItem gridItem = (GridDataItem)RadGrid1.SelectedItems[0];
        Hashtable fieldValues = gridItem.ExtractValues(fieldValues);
       
       .....
      
    }

    Hope it helps.

    Greetings,
    Tsvetoslav
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    thanks !
  6. JJ
    JJ avatar
    147 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    thabk you Tsvetoslav !
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017