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

AllowRowSelect="True with Server side processing

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 18 Aug 2008, 11:04 PM
Hello,

In the Asp.Net Grid view control I would add three attributes that would allow the row to change color when highlighted and when a row was clicked on it would call the gridview_rowcomand event.

I would like to be able to do this in the RadGrid. Here is what I have so far:

 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
 
            if (e.Item is GridDataItem )  
            {  
 
 
                e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'");  
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFF'");     
                e.Item.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.RadGrid1, "Select$" + e.Item.ItemIndex,true);  
 
 
            }  
 
 
        } 

When I click on the row a post back fires but the Item_Command event is never called. How can I make this work? Here what I want to do:

1) Change BG color on Hover - done
2) When User clicks on a row preform a server side postback that tells me what row was selected.

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 19 Aug 2008, 04:32 AM
Hi,

Try setting EnablePostBackOnRowClick to true in the ClientSettings of the Grid.

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

CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "RowClick") 
        { 
            
        } 
    } 

Thanks
Princy.
0
Larry
Top achievements
Rank 1
answered on 30 Jan 2012, 05:27 PM
when I do this, e.CommandName is null

0
Shinu
Top achievements
Rank 1
answered on 31 Jan 2012, 05:59 AM
Hello Larry,

I tried the same scenario in the version 2011.2.915.35 which worked as expected. Make sure that you have set EnablePostBackOnRowClick as true.

-Shinu.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or