This is an ASP.Net 2.0 web application. The element template is as follows:
<ItemTemplate> <tr> <td class="class1" align=center><a href='url'><img src="img.gif"></a></td> <td class="class1"><%# DataBinder.Eval(Container.DataItem,"field1") %></td> <td class="class1"><%# DataBinder.Eval(Container.DataItem,"field2") %></td> <td class="class1"><%# DataBinder.Eval(Container.DataItem,"field3") %></td> <td class="class1"><%# DataBinder.Eval(Container.DataItem,"field4") %></td> </tr> </ItemTemplate>
Using this in codebehind:
foreach (RepeaterItem item in rptrFollowupSummary.Items) { string val = ((DataBoundLiteralControl)item.Controls[0]).Text; Trace.Write(val); }
I create this:
<tr> <td class="class1" align=center><a href='url'><img src="img.gif"></a></td> <td class="class1">23</td> <td class="class1">1/1/2000</td> <td class="class1">-2</td> <td class="class1">11</td> </tr>
I need data from Field1 and Field4
It seems I can’t get the data as I would say, DataList or GridView, and I can’t come up with anything else on Google or use it quickly to do what I want. The only way I can get the data is to use a regular expression to go and get it (because the person takes what he wants. He takes it all. And I'm human, right? Me?).
Am I on the right track (not looking for a specific regular expression to do this, fake, which may be the next question;)), or am I missing something?
Repeater in this case is set in stone, so I can not switch to something more elegant. Once I did something similar to what Alison Zhou suggested using DataLists, but it was some time (2+ years), and I just completely forgot about it. Yish, talk about skipping something obvious.,.
So, I did what Alison suggested, and everything works fine. I do not think that there is a problem in this view, although this relay can receive dozens of lines. I can't answer the question if you do it this way against using it instead (but this seems like a great solution for me otherwise). Obviously, the latter has less visibility, but I'm not experienced enough to say when one approach may be preferable to another without an extreme example in front of me. Alison, one question: why are literals and not shortcuts?
Euro Micelli, I tried to avoid a trip back to the database. Since I'm still a little green relative to the rest of the development world, I admit that I don’t necessarily know how many flights to the database are “correct”. There would be no performance issue (I know that the application is enough to know this), but I believe that I tried to avoid this out of habit, as my boss tends to emphasize fewer trips where possible.