Store Value from Data Repeater

C

Christine Y.

I'm using a data repeater to get ID values from a simple table in my
database and display them on my .aspx page (this is working):

<ItemTemplate>
<tr>
....
<td><%# DataBinder.Eval(Container, "DataItem.MyID") %></td>
....
<tr>
</ItemTemplate>

Now, I want to be able to store the value I get from
DataBinder.Eval(...) into a string and call a function in my code
behind (from within the .aspx page, passing that string). Is this
possible? I'm a newbie to ASP.NET, ADO.NET and C#, so any help would
be greatly appreciated! Thanks!

Christine
 
C

Christine Y.

Okay, I figured it out. I can just use that same DataBinder line as an
argument to my code-behind function, so I would have something like:

****.aspx page****
....
<td><%# DataBinder.Eval(Container, "DataItem.MyID") %></td>
<td><%# GetUserName((string)DataBinder.Eval(Container,
"DataItem.MyID")) %></td>
....

****c# code behind****

protected string GetUserName(string ID) { ... }

NOTE: I had to cast the argument as a string in order to get the call
to work.

Christine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top