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

Get edit input id in a grid build programmatically

1 Answer 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Blop
Top achievements
Rank 1
Blop asked on 11 Jun 2012, 03:15 PM
Hello,
For some reasons I have to build my gridview programmatically. 
One of the column is build like this: 

  Dim myColumn As GridBoundColumn
        myColumn  = New GridBoundColumn
        myColumn .DataField = "myValue"
        myColumn.HeaderText = "Value"
        myColumn.UniqueName = "myValue"

The gridview is editable. When I click on the edit button (and an input text appears) I want to get the input id with javascript. 
How can I do that? 
Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jun 2012, 05:48 AM
Hi Blop,

I guess you need the clientID of the TextBox in Javascript on Editing.

C#:
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem eitem=(GridEditableItem)e.Item;
        TextBox textbox = (TextBox)eitem["UniqueName"].Controls[0];
        textbox.Attributes.Add("OnBlur", "return show('" + textbox.ClientID + "')"); 
    }
}

Javascript:
<script type="text/javascript">
    function show(cntid)
    {
        alert(cntid);
    }
</script>

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