This is a migrated thread and some comments may be shown as answers.

row select

9 Answers 283 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ibrahim
Top achievements
Rank 1
ibrahim asked on 10 Mar 2009, 02:32 PM
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

9 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 10 Mar 2009, 03:44 PM
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.
0
ibrahim
Top achievements
Rank 1
answered on 11 Mar 2009, 06:56 AM
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
0
Accepted
Riaan
Top achievements
Rank 1
answered on 11 Mar 2009, 08:06 AM

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?

0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Mar 2009, 08:07 AM
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
0
ibrahim
Top achievements
Rank 1
answered on 11 Mar 2009, 09:20 AM
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?
0
Riaan
Top achievements
Rank 1
answered on 11 Mar 2009, 09:33 AM
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()); 
0
ibrahim
Top achievements
Rank 1
answered on 11 Mar 2009, 09:49 AM
i am selecting by clicking:S so i don't think it will work
0
Princy
Top achievements
Rank 2
answered on 11 Mar 2009, 10:25 AM
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.
0
ibrahim
Top achievements
Rank 1
answered on 11 Mar 2009, 12:46 PM
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



Tags
Grid
Asked by
ibrahim
Top achievements
Rank 1
Answers by
Daniel
Telerik team
ibrahim
Top achievements
Rank 1
Riaan
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or