Reputation: 3675
In my aspx page, I have a detailsView and a label. The label's text should show the same value as a boundfield of the detailsview. How do I get both of them populated at the same time? Following is my apsx page, I tried the Eval, it didn't work. I don't want to do it in the code-behind.
<tr>
<td > <asp:label runat="server" text='<%# Eval("ReporterName")%>'/></td>
</tr>
<tr>
<td>
<asp:DetailsView ID="DetailsView1" runat="server" >
<Fields>
<asp:BoundField DataField="sprID" HeaderText="SPRID" ReadOnly="True"
SortExpression="sprID" >
<HeaderStyle Width="230px" />
</asp:BoundField>
<asp:BoundField DataField="ProductName" HeaderText="Product"
SortExpression="ProductName" />
<asp:BoundField DataField="DivisionName" HeaderText="Technology Group"
SortExpression="DivisionName" />
<asp:BoundField DataField="DisciplineName" HeaderText="Discipline"
SortExpression="DisciplineName" />
<asp:BoundField DataField="ReporterName" HeaderText="Reporter"
SortExpression="ReporterName" />
<asp:BoundField DataField="OwnerName" HeaderText="Owner"
SortExpression="OwnerName" />
<asp:BoundField DataField="SalesLeadName" HeaderText="SalesLead"
SortExpression="SalesLeadName" />
<asp:BoundField DataField="RegionName" HeaderText="Region"
SortExpression="RegionName" />
</Fields>
Upvotes: 0
Views: 1914
Reputation: 46047
Try using the DataBound
event, like this:
protected void DetailsView1_DataBound(object sender, EventArgs e)
{
Label1.Text = DataBinder.Eval(DetailsView1.DataItem, "SomeValue").ToString();
}
Upvotes: 1