473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

datalist problem

40
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:
Expand|Select|Wrap|Line Numbers
  1.       <asp:DataList ID="dlEvents" runat="server" HorizontalAlign="Left" GridLines="Both"
  2.                         OnSelectedIndexChanged="SelectedIndexChanged">
  3.                         <HeaderTemplate>
  4.                             Events
  5.                         </HeaderTemplate>
  6.                         <HeaderStyle Font-Bold="true" Font-Size="16px" />
  7.                         <ItemTemplate>
  8.                             <table onmouseover="dg_changeBackColor(this, true);" onmouseout="dg_changeBackColor(this, false);">
  9.                                 <tr>
  10.                                     <td>
  11.                                         <%--  <asp:Label ID="lblEvntId" runat="server" Text='<%# Bind("prison_event_id") %>' Visible="false"></asp:Label>--%>
  12.                                         <asp:Label ID="lblEvntTitle" runat="server" Text='<%# Bind("prison_event_title") %>'></asp:Label>
  13.                                         <asp:Label ID="lblEvntId" runat="server" Text='<%# Bind("prison_event_id") %>' Visible="false"></asp:Label>
  14.                                         <asp:Label ID="lblEvntDate" runat="server" Text='<%# Bind("prison_event_date") %>'
  15.                                             Visible="false"></asp:Label></td>
  16.                                     <asp:Label ID="lblEvntVenue" runat="server" Text='<%# Bind("prison_event_venue") %>'
  17.                                         Visible="false"></asp:Label>
  18.                                     <asp:TextBox ID="txtEvntDesc" runat="server" Text='<%# Bind("prison_event_description") %>'
  19.                                         ReadOnly="true" Visible="false"></asp:TextBox>
  20.                                     <asp:Button CommandName="Select" runat="server" Text="View Details" ID="btnEvntDetails">
  21.                                     </asp:Button>
  22.                                     </td>
  23.                                 </tr>
  24.                             </table>
  25.                         </ItemTemplate>
  26.                     </asp:DataList></div>
  27.                 <div id="body-right">
  28.                     <table id="tblEvntDetails">
  29.                         <tr>
  30.                             <td>
  31.                                 <asp:Label ID="lblEvntId" runat="server" Visible="false"></asp:Label>
  32.                             </td>
  33.                         </tr>
  34.                         <tr>
  35.                             <td>
  36.                                 <asp:Label ID="lblEvntTitle" runat="server"></asp:Label></td>
  37.                         </tr>
  38.                         <tr>
  39.                             <td>
  40.                                 <asp:Label ID="lblEvntDate" runat="server"></asp:Label></td>
  41.                         </tr>
  42.                         <tr>
  43.                             <td>
  44.                                 <asp:Label ID="lblEvntVenue" runat="server"></asp:Label>
  45.                             </td>
  46.                         </tr>
  47.                         <tr>
  48.                             <td>
  49.                                 <asp:TextBox ID="txtEvntDesc" runat="server" ReadOnly="true"></asp:TextBox>
  50.                             </td>
  51.                         </tr>
  52.                     </table>
  53.  
the codebehind has the following code
Expand|Select|Wrap|Line Numbers
  1.   protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!Page.IsPostBack)
  4.         {
  5.             this.loadData();
  6.  
  7.         }
  8.     }
  9.  
  10.     protected void loadData()
  11.     {
  12.  
  13.         BLL_NewsAndEvents objNe = new BLL_NewsAndEvents();
  14.         objNe.viewEvents(this.dlEvents);
  15.         objNe.Close();
  16.  
  17.     }
  18. protected void SelectedIndexChanged(object sender, EventArgs e)
  19.     {
  20.        //  string ID = (String)dlEvents.DataKeyField;
  21.        Label lblEvntId = (Label)dlEvents.SelectedItem.FindControl("lblEvntId");
  22.         Label lblEvntTitle = (Label)dlEvents.SelectedItem.FindControl("lblEvntTitle");
  23.         Label lblEvntDate = (Label)dlEvents.SelectedItem.FindControl("lblEvntDate");
  24.         Label lblEvntVenue = (Label)dlEvents.SelectedItem.FindControl("lblEvntVenue");
  25.         TextBox txtEvntDesc = (TextBox)dlEvents.SelectedItem.FindControl("txtEvntDesc");
  26.  
  27.  
  28.     }
  29.  
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
Apr 30 '10 #1
1 1032
lisles
40
thanx.I changed my code a bit...
Expand|Select|Wrap|Line Numbers
  1.        <asp:DataList ID="dlEvents" runat="server" Width="90%" GridLines="both" CellPadding="5"
  2.                           OnSelectedIndexChanged="SelectedIndexChanged" DataKeyField="prison_event_title">
  3.                          <%--OnItemCommand="getSelected"--%>
  4.                         <HeaderStyle BackColor="lightsteelblue"/>
  5.                         <SelectedItemStyle BackColor="lightgreen" />
  6.                         <HeaderTemplate>
  7.                             Titles
  8.                         </HeaderTemplate>
  9.                         <ItemTemplate>
  10.                             <asp:LinkButton ID="Linkbutton1" runat="server" CommandName="select" Text='<%# Bind("prison_event_title") %>' />
  11.                         </ItemTemplate>
  12.                         <SelectedItemTemplate>
  13.                             <asp:DataList ID="dlEvntDetails" runat="server">
  14.                             <HeaderTemplate>
  15.                             Event Details
  16.                             </HeaderTemplate>
  17.                             <ItemTemplate><div id="title" class="title" runat="server">
  18.                                 <asp:Label ID="lblEvntTitle" runat="server" Text='<%# Bind("prison_event_title") %>'></asp:Label></div>
  19.                                 <asp:Label ID="lblEvntId" runat="server" Text='<%# Bind("prison_event_id") %>' Visible="false"></asp:Label>
  20.                                 <asp:Label ID="lblEvntDate" runat="server" Text='<%# Bind("prison_event_date") %>'></asp:Label></td>
  21.                                 <asp:Label ID="lblEvntVenue" runat="server" Text='<%# Bind("prison_event_venue") %>'></asp:Label>
  22.                                 <asp:TextBox ID="txtEvntDesc" runat="server" Text='<%# Bind("prison_event_description") %>'
  23.                                     ReadOnly="true"></asp:TextBox></ItemTemplate>
  24.                             </asp:DataList>
  25.  
  26.  
  27.  
  28.                         </SelectedItemTemplate>
  29.                     </asp:DataList>
  30.  
and thhe code behind is
Expand|Select|Wrap|Line Numbers
  1.     protected void SelectedIndexChanged(object sender, EventArgs e)
  2.     {
  3.  
  4.         Label lblEvntId = (Label)dlEvents.SelectedItem.FindControl("lblEvntId");
  5.         Label lblEvntTitle = (Label)dlEvents.SelectedItem.FindControl("lblEvntTitle");
  6.         Label lblEvntDate = (Label)dlEvents.SelectedItem.FindControl("lblEvntDate");
  7.         Label lblEvntVenue = (Label)dlEvents.SelectedItem.FindControl("lblEvntVenue");
  8.         TextBox txtEvntDesc = (TextBox)dlEvents.SelectedItem.FindControl("txtEvntDesc");
  9.         DataList dlEvntDetails = (DataList)dlEvents.SelectedItem.FindControl("dlEvntDetails");
  10.         BLL_NewsAndEvents objNE = new BLL_NewsAndEvents();
  11.         objNE.viewEvntDetails(dlEvntDetails, txtEvntDesc.Text.Trim(), lblEvntVenue.Text.Trim(), lblEvntDate.Text.Trim(), lblEvntTitle.Text.Trim(), lblEvntId.Text.Trim());
  12.         objNE.Close();
  13.  
  14.     }
  15.  
  16.  
but the values are not gettin passed to the codebehind...please tell me wot to do
Apr 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Antonio D'Ottavio | last post by:
Good Morning, In my web page I've a datalist that is sourced by a database, the problem is that I want that one of the column of the datalist contain a dropdownbox that also is sourced by a table...
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
2
by: scottls | last post by:
Hi All, Thanks for reading my post. I have been working on getting nested datalists working properly wihtin my framework for many days and I think I'm almost there. See if you could help me...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.