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

Get Controls in RadGrid's Edit ItemTemplate in Jquery

1 Answer 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 03 May 2012, 05:32 AM
I have used textbox,label in all GridTemplateColumn's EditItemTemplate. I am unable to get the id of those controls when trying it in jquery.
I tried this method too.

var grid = $find("<%=Grid1.ClientID %>");
var masterTable = grid.get_masterTableView();
var row = masterTable.get_dataItems();
var button = row.findElement("controlname");

But I couldn't get the ID.

If the Grid is in ICGRadAjaxManager's updated control, will the above code work?

Thanks in advance

Vijay.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 May 2012, 06:33 AM
Hello Vijay,

Try the following code to access controls in Edititemtemplate.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
 if (e.Item is GridEditableItem && e.Item.IsInEditMode)
 {
   GridEditableItem item = (GridEditableItem)e.Item;
   TextBox txt = (TextBox)item.FindControl("TextBox2");
   RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['txt'] = '" + txt.ClientID + "';</script>"));
 }
}
JS:
<script type="text/javascript" src="jquery-1.3.2-vsdoc2.js"></script>
 <script type="text/javascript">
 $(document).ready(function ()
{
 var txt = document.getElementById(window['txt']);
});
</script>

Thanks,
Shinu.
Tags
Grid
Asked by
Vijay
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or