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

Get RadGrid Eval Value from Hiddenfield with Javascript to C# Codebehind

1 Answer 203 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 2
Jason asked on 17 Dec 2009, 10:38 AM

I am trying to get an Eval value from my radgrid to my c# codebehind.  The value is binded to a hiddenfield and I want to get the value after I hit the built in edit button.  To achieve this I am trying to get the hiddenvalue1 to javascript and then somehow get it to my c# code behind.  The closest thing I have come to that is binding the value to a hyperlink that when clicked shows an alert with the binded value as shown below.  I need something that is automatic where I don’t need to hit a button.  Can anyone help?

 

<asp:HyperLink id="hklk" runat="server" Text='<%# Eval("id") %>' onclick="return GiveAlert(this);"></asp:HyperLink>

 

function GiveAlert(con)

{

 

     alert(con.innerHTML);

 

     return false;

}

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Dec 2009, 11:29 AM
Hi Adisa,

You can access the item in EditMode and then access the control placed in EditItemTemplate as shown below in ItemDataBound event.

ASPX:
 
    <telerik:GridTemplateColumn> 
    <ItemTemplate> 
       . . . 
    </ItemTemplate> 
    <EditItemTemplate> 
        <asp:HyperLink ID="hklk" runat="server">HyperLink</asp:HyperLink> 
    </EditItemTemplate> 
    </telerik:GridTemplateColumn> 

CS:
 
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            HyperLink hyperLink = (HyperLink)editItem.FindControl("hklk"); 
            String text = hyperLink.Text; 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Jason
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or