row select

10 posts, 2 answers
  1. ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 10 Mar 2009 Link to this post

    guys how can i select  a certain row just by clicking on it ....on the first one i want the table with no full details once clicked the grid should display the rest of the details from the first grid...using the datakey is that possible? or should i add a select command....
    also how can i add a checkbox field on the grid?? and be able to select or deselct just by pushing in the grid....please can you provide the code in vb,net
  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 10 Mar 2009 Link to this post

    Hello Ibrahim,

    Have a look at the following links:
    Server-side row selection
    Client-side row selection
    NestedView template
    Related grids

    Let us know if you have any specific question.

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    ok that is the issue...there is no autopost back property...and i wrote a radgrid1.selectedindexchanged...and it is never executed....what should i do...am i supposed to write a javescript code???

    thanks in advanced
  5. Answer
    Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 11 Mar 2009 Link to this post

    Hi Ibrahim,

    I had a similar reuirement before, the way I got it to work was to add a SelectCheckbox column to the grid, and then on the checkchanged event of the control I wired the needed functionality to show my div and grid below the top grid. I also filtered the second grid depending on what I selected in the first grid. Does this help?

  6. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2009 Link to this post

    Hi Ibrahim,

    From my understanding the SelectedIndexChanged event of the Grid will fire only if a postback happens while selecting the row. For that you can set the EnablePostBackOnRowClick property to true.

    ASPX:

    <
    ClientSettings   EnablePostBackOnRowClick="true" > 
                </ClientSettings> 

    Thanks
    Shinu
  7. ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    ok guys thanks it works:)
    but now what i really want is to get the key of the selected row
    with asp.net gridview its easy but here i cannot find a method to help me do that ..any sugestions?
  8. Riaan
    Riaan avatar
    17 posts
    Member since:
    Jan 2009

    Posted 11 Mar 2009 Link to this post

    Hi, what I usually do is use a Hashtable to get the key of the selected item. Hope this helps.
    Telerik.Web.UI.GridDataItem editedItem = e.Item as Telerik.Web.UI.GridDataItem;  
     
     
    Hashtable rowVals = editedItem.OwnerTableView.DataKeyValues[e.Item.ItemIndex];  
     
    //get the value if the item is an int value for string use string etc.  
    int _myvalue = int.Parse(rowVals["TimeID"].ToString()); 
  9. ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    i am selecting by clicking:S so i don't think it will work
  10. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2009 Link to this post

    Hello Ibrahim,

    You can try out the following code to retrieve the datakeyvalue on the click of a row:
    cs:
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "RowClick"
            { 
                if (e.Item is GridDataItem) 
                { 
                    GridDataItem item = (GridDataItem)e.Item; 
                    string strtxt = item.GetDataKeyValue("DataKeyName").ToString(); 
                } 
            } 
        } 

    Thanks
    Princy.
  11. ibrahim
    ibrahim avatar
    74 posts
    Member since:
    Feb 2009

    Posted 11 Mar 2009 Link to this post

    thanks guys i used 
    Private Sub RadGrid2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid2.SelectedIndexChanged

        
    <div> dim key as string</div><br/> 
    <div>key=RadGrid2.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid2.SelectedItems(0).ItemIndex).Values(0).ToString</div> 
     
    and it worked just fine thanks



Back to Top
UI for ASP.NET Ajax is Ready for VS 2017