Skip to content Skip to sidebar Skip to footer

How To Get Cell Value From A Gridview?

Friends, I've a gridview in my web-page designed in the following manner:-
Copy

Solution 2:

What is the purpose? For eg. If you want to delete or edit the particular item, on click of a button in the table row ?

Solution 3:

I would use JQuery to access to last instance of Label5 within the divProducts. Firstly I would add an additional class to Label5 so that it is marked different from all the other spans in the table (Note:asp:Label will render a SPAN)

<asp:LabelID="Label5"runat="server"Text='<%# Eval("USER_ACTIVITIES_ID") %>'CssClass="labelCss useractivity"></asp:Label>

Then something like this to find it on the client.

var id=$("#divProducts").children("span[class=useractivity]:last").text();

Solution 4:

Ok. What I Guess you want to do is pagination. If I'm right, there are many many many tutorials to do table pagination (paging of bulk rows, in a numbered sequence). In ASP.Net I think there is a property called 'AlloWPaging' for the standard 'GridView' control.

Solution 5:

This is the best idea from my side then. -

Use DOM to iterate through the <tr> elements. First take the <table> element. Then get the firstChild. While there are more <tr> elements inside the <table> element keep on iterating. When you get the last '' element, you are there.

You can look for the TD in that last TR, where your last USER_ACTIVITY_ID is stored. Then you can get the inner text value. A simple example will be -

getTextFromTD = function() {
var gridView = document.getElementById("myGridView");
var lastTR = gridView.childNodes.item(5);
var ourRequiredTD = lastTR.childNodes(2);
requiredText = ourRequiredTD.innerHTML;
}

(Sometimes it becomes difficult to help when the actual code is not infront of me.)

Post a Comment for "How To Get Cell Value From A Gridview?"