0

I am trying to pass row index from inside my gridview to javascript function and I am getting an error that databind does not contain a property name container.

<label style="text-decoration: underline" onclick="javascript:GetSelectedRow('<%# Eval("ID") %>','<%# Eval("root__level") %>','<%# Eval("ParentMclid") %>','<%# Eval("systempath") %>','<%# Eval("Container.DataItemIndex + 1") %>);"><%#Eval("ID") %></label>

I just want to pass the rowindex of the gridview to the javascript function. .

1
  • With JavaScript you can just query the DOM and determine which row was clicked. Commented Nov 13, 2012 at 16:22

1 Answer 1

2

Try <%# Container.DataItemIndex %> instead.

Container is an object exposed to you during data binding, you don't need to include it in your Eval statement. Only use Eval when you need to access a property or item in your data source. Also, Eval("chicken") is really a shortcut to DataBinder.Eval(Container, "chicken").

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.