Hi,
I am using a ListView to display info from the DB. I wanted to use the emailaddress that is being binded into the Email label control through the Eval keyword.
Code:
protected void ViewAllProperty_ItemCreated(object sender, ListViewItemEventArgs e)
{
// Label EmailTB;
if (e.Item.ItemType == ListViewItemType.DataItem)
{
// EmailTB = (Label)e.Item.FindControl("EmailTB");
ListViewDataItem dataItem = (ListViewDataItem) e.Item;
string currentEmailAddress = (string) DataBinder.Eval(dataItem.DataItem, "EmailTB");
DataRowView rowView = (DataRowView)dataItem.DataItem;
string Username = Membership.GetUserNameByEmail(currentEmailAddress);
lbUsername.Text = Username;
}
}
With this I am getting this error:
System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'EmailTB'.
thx