i have a datalist that displays the titles of events.When i click a title i want to display the event details like date,venue,description... outside the datalist
this is my code:
<asp:DataList ID="dlEvents" runat="server" HorizontalAlign="Left" GridLines="Both"
OnSelectedIndexChanged="SelectedIndexChanged">
<HeaderTemplate>
Events
</HeaderTemplate>
<HeaderStyle Font-Bold="true" Font-Size="16px" />
<ItemTemplate>
<table onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
<tr>
<td>
<%-- <asp:Label ID="lblEvntId" runat="server" Text='<%# Bind("prison_event_id") %>' Visible="false"></asp:Label>--%>
<asp:Label ID="lblEvntTitle" runat="server" Text='<%# Bind("prison_event_title") %>'></asp:Label>
<asp:Label ID="lblEvntId" runat="server" Text='<%# Bind("prison_event_id") %>' Visible="false"></asp:Label>
<asp:Label ID="lblEvntDate" runat="server" Text='<%# Bind("prison_event_date") %>'
Visible="false"></asp:Label></td>
<asp:Label ID="lblEvntVenue" runat="server" Text='<%# Bind("prison_event_venue") %>'
Visible="false"></asp:Label>
<asp:TextBox ID="txtEvntDesc" runat="server" Text='<%# Bind("prison_event_description") %>'
ReadOnly="true" Visible="false"></asp:TextBox>
<asp:Button CommandName="Select" runat="server" Text="View Details" ID="btnEvntDetails">
</asp:Button>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList></div>
<div id="body-right">
<table id="tblEvntDetails">
<tr>
<td>
<asp:Label ID="lblEvntId" runat="server" Visible="false"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblEvntTitle" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="lblEvntDate" runat="server"></asp:Label></td>
</tr>
<tr>
<td>
<asp:Label ID="lblEvntVenue" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtEvntDesc" runat="server" ReadOnly="true"></asp:TextBox>
</td>
</tr>
</table>
the codebehind has the following code
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.loadData();
}
}
protected void loadData()
{
BLL_NewsAndEvents objNe = new BLL_NewsAndEvents();
objNe.viewEvents(this.dlEvents);
objNe.Close();
}
protected void SelectedIndexChanged(object sender, EventArgs e)
{
// string ID = (String)dlEvents.DataKeyField;
Label lblEvntId = (Label)dlEvents.SelectedItem.FindControl("lblEvntId");
Label lblEvntTitle = (Label)dlEvents.SelectedItem.FindControl("lblEvntTitle");
Label lblEvntDate = (Label)dlEvents.SelectedItem.FindControl("lblEvntDate");
Label lblEvntVenue = (Label)dlEvents.SelectedItem.FindControl("lblEvntVenue");
TextBox txtEvntDesc = (TextBox)dlEvents.SelectedItem.FindControl("txtEvntDesc");
}
but when i run the code the get the following error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'prison_event_id'.I have 'prison_event_id' in my table
please tell me wot to do