Click here to Skip to main content
16,022,669 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
I have a scenario where i need a particular index of a column using column name in the Datagrid using jQuery.
Posted
Updated 7-May-14 8:14am
v2
Comments
So, what have you tried?
NaveenChidara 7-May-14 14:28pm    
here is my actual code:
var index = $('#<%=ucProduct.FindControl("m_grid").ClientID%> thead tr').index('.SubProductLive');

where 'ucProduct' is my usercontrol and 'm_grid' as datagrid in my usercontrol.
Here i need the column index (having a class name as 'SubProductLive') and i tried above but i get index as -1. Please help
Before trying the code, analyze the rendered HTML in browser. See how the controls and elements you are trying to get are organized. Then it would give you the idea how to exactly get the index. Reply me with your observations.
NaveenChidara 8-May-14 12:52pm    
Thanks for your reply Tadit. I was able to solve this using class name for the element like this.
$('#<%=ucProduct.FindControl("m_grid").ClientID%> tr').each(function() {

liveFlag = $(this).find('.SubProductLive').html();
});

and use the liveflag for my funtionality.
Thanks once again.
Glad to hear that. Good work, keep it up. :)

I have added one answer, please accept that.

Thanks,
Tadit

1 solution

Before trying the code, analyze the rendered HTML in browser. See how the controls and elements you are trying to get are organized. Then it would give you the idea how to exactly get the index. Reply me with your observations.
Quote:
Thanks for your reply Tadit. I was able to solve this using class name for the element like this.
JavaScript
$('#<%=ucProduct.FindControl("m_grid").ClientID%> tr').each(function() {

liveFlag = $(this).find('.SubProductLive').html();
});

and use the liveflag for my funtionality.
Thanks once again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900