views:

297

answers:

1

Hi, I have a textbox inside my datagrid whose id need to be passed to javascript.The id of my datagrid is Datagrid1 and that of textbox is txtItem.All these are inside a contentplaceholder.Now i have passed the id of textbox as ct100_ContentPlaceholder1_Datagrid1_txtItem.It shows an error in my javascript as "Object reference not set to an instance of an object".How can i pass the id of this textbox which is inside a datagrid to javascript.

+2  A: 

If you have a textbox inside your grid probably you have multiple instances of it, with JQuery you can access all textboxes inside your grid like that :

function getTextBoxesInsideGrid()
{
    var gridClientID = '<%= grid.ClientID %>';
    jQuery.each($("#" + gridClientID + " input[type='text']"), function ()
    {
      var textValue = this.val();
      // do something
    });
}
Canavar