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

Passing data to a GridButtonColum event handler

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 17 Sep 2008, 09:47 AM
Hi,

I have a RadGrid which contains a GridButtonColumn with a LinkButton inside. If the user clicks this Link, a RadWindow opens which shows a detail page for the clicked record. Now I need to pass the data key for that record to the RadWindow. Therefore I have created an invisible column in the RadGrid which contains these keys.
The problem is, to determine which record has been clicked and to pass the according value to the opened window.

I use the RadGrid's ItemCommand Event to open the window. How can I pass data from the grid to the event handler?

Best regards,
Robert

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Sep 2008, 12:40 PM
Hello Robert,

       You can try out the following code to open a RadWindow and pass the DataKeyValue to the window.
cs:
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
         if (e.Item is GridDataItem) 
            { 
                GridDataItem dataItem = (GridDataItem)e.Item; 
                string key=dataItem.GetDataKeyValue("FirstName").ToString(); 
                LinkButton lnkbtn = (LinkButton)dataItem["Button"].Controls[0]; 
                lnkbtn.Attributes.Add("OnClick", "return ShowWindow('" + key + "')"); 
            } 
    } 

js:
function ShowWindow(key) 
            {                        
                 var Wnd = radopen("Default7.aspx?FirstName=" +key, "RadWindow1" ); 
                 return false; 
            } 

Princy.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or