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.

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s