2

I'm trying to figure out how to get this value in the code behind. Any way to do this?

returned <%# DataBinder.Eval(Container.DataItem, "PagesFound")%> results. Showing results 1

Its part of datalist, and when I try to get the count from the datalist it isn't correct. meaning if it the value from the databinder.eval above is "7", the item count from the datalist will show 2.

2 Answers 2

2

You call the function this way

<asp:TemplateField HeaderText="Header Title" >
   <ItemTemplate ><%#GetYourData(Container.DataItem)%></ItemTemplate>
</asp:TemplateField>                

and the code behind.

protected string GetYourData(object oItem)
{
   return DataBinder.Eval(oItem, "PagesFound").ToString();
}
Sign up to request clarification or add additional context in comments.

Comments

0

An idea will be to put the PagesFound in a HiddenField inside the DataList and then using FindControl on that.

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.