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,desc ription... outside the datalist
this is my code:
the codebehind has the following code
but when i run the code the get the following error:
DataBinding: 'System.Data.Da taRowView' does not contain a property with the name 'prison_event_i d'.I have 'prison_event_i d' in my table
please tell me wot to do
this is my code:
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>
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"); }
DataBinding: 'System.Data.Da taRowView' does not contain a property with the name 'prison_event_i d'.I have 'prison_event_i d' in my table
please tell me wot to do
Comment