multiple Eval statements in one control
Is it possible to have several <%# Eval("something")%> statements in one control, and if so, what am i doing wrong?
i'm trying to add hyperlinks to a datalist, where the navigateurl and text are retrived from a datatable i use use as datasource.
this is how i make my datatable
foreach (Google.GData.Calendar.EventEntry ev in calFeed.Entries)
{
ExtensionCollection<When> v = ev.Times;
DataRow Title = dt.NewRow();
DataRow url = dt.NewRow();
Title["title"] = ev.Title.Text;
url["url"] = ev.Content.Content;
dt.Rows.Add(Title);
dt.Rows.Add(u开发者_如何学Gorl);
dt.AcceptChanges();
}
this is my html
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<asp:HyperLink NavigateUrl='<%# Eval("url")%>' runat="server" Text=<%# Eval("title")%> />
</ItemTemplate>
</asp:DataList>
now if i eval title in both fields they are shown, but if i chose two different like title and url, only one is evaluated, and the other is left blank.
You are creating two rows, in your code. Create just one row in your code and then add it:
foreach (Google.GData.Calendar.EventEntry ev in calFeed.Entries)
{
ExtensionCollection<When> v = ev.Times;
DataRow dr = dt.NewRow();
dr["title"] = ev.Title.Text;
dr["url"] = ev.Content.Content;
dt.Rows.Add(dr);
dt.AcceptChanges();
}
精彩评论