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

How to pass a data value from RadGrid using Javascript...

1 Answer 273 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 27 Feb 2009, 05:37 PM
Is it possible to do something like this?

<telerik:GridTemplateColumn HeaderText="" UniqueName="TemplateColumn3">
<ItemTemplate>
<asp:ImageButton ID="info" runat="server" OnClientClick="addsubmenu(<%# Eval("DestID") %>)" ImageUrl="~/globalgraphics/webicons/info.jpg" />
</ItemTemplate>
</telerik:GridTemplateColumn>

 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Mar 2009, 11:22 AM
Hello Larry,

You can try out the following code to pass a cell value from server side to the client:
cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            // save the datafield as the DataKeyName of the grid and retrieve the value 
           string text1 = dataItem.GetDataKeyValue("ID").ToString();// ID refers to the column unique name of the cell, data of which needs to passed 
            //OR 
            string text1 = dataItem["ID"].Text;//access the cell text 
 
            ImageButton imgbtn = (ImageButton)dataItem["TemplateColumn3"].FindControl("info"); 
            imgbtn.Attributes.Add("onClick""return addsubmenu('" + text1 + "')"); 
 
        } 
  } 

js:
function addsubmenu(text) 
    alert(text); 

Thanks
Princy.
Tags
Grid
Asked by
Michele
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or