Databinding "Bind()" in ASP.NET

If you used the developemt tools to create a datagrid in ASP.NET 2.0, it will show something like:

NavigateUrl=’<%# Bind(“EmployeeId”) %>

But what if you wanted to do something more complicated that just ge the EmployeeId into the field, like for example if you wanted to run a JS function.  Then you have to do away with Bind and use the more verbose DataBinder method like this: 

NavigateUrl=’<%# “javascript:UseThisJobIndex(” & DataBinder.Eval(Container.DataItem,”JobIndex”) & “)” %>

That’s all there is to it.

 

Leave a comment