i m shoeing different fields from database also i m using a variable"totRent2" from codebehind in itemtemplate of datalist
all works fine axcept variable problem is that.
if i use"<%=totRent2%>" it overWrite by the last calculated total(say car a has totrent 10,car b has totrent 20 and car c has totrent 30 in code behind but it show 40 for all cars total)
if i use"<%#totRent2%>" it works but it does'nt show totrent for car a instead it shows the totrent of car a in car b car b in car c
any idea to solve this or any other idea for this solution..........................
<
asp:DataList ID="DataList1" runat="server" BackColor="White"
BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4"
DataKeyField="Car_id" DataSourceID="AccessDataSource1" GridLines="Both"
Width="345px"
Height="278px" CssClass="TextLabelWhite"
onitemdatabound="DataList1_ItemDataBound" EditItemIndex="-1" SelectedIndex="-1">
<FooterStyle BackColor="#FFFFCC" BorderColor="#FF9900" BorderStyle="Solid"
ForeColor="#330099" />
<ItemStyle BackColor="White" BorderStyle="Solid" ForeColor="#330099" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<ItemTemplate>
<table align="right" width="530px">
<tr>
<td width="50">
<IMG height=50 src='../../Images/Fleet/<%#Eval("Car_picture")%>' width=75 border=0 title="<%#Eval("Car_Name")%>" />
</td>
<td width="20px">
<asp:Label ID="Car_idLabel" runat="server" Text='<%# Eval("Car_id") %>' />
</td><td width="20px">
<asp:Label ID="Car_groupLabel" runat="server" Text='<%# Eval("Car_group") %>' />
</td><td width="205px">
<asp:Label ID="Car_NameLabel" runat="server" Text='<%# Eval("Car_Name") %>' />
</td>
<td>
<asp:Label ID="Label7" runat="server" Text='<%#totRent2%>'></asp:Label></td>// ....Here is Problem---------------------------
<td width="110px">
<asp:Label ID="CategoryLabel" runat="server" Text='<%# Eval("Car_Category") %>' />
<br /></td><td><br /><br /><a href="SelectOptions.aspx?Car_ID=<%# Eval("Car_id") %>"><asp:Label ID="Label1" runat="server">Select </asp:Label></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
int it = e.Item.ItemIndex;
id = (int)DataList1.DataKeys[it];
Bll bll = new Bll();
DataSet ds = bll.sendSelectedCarID(id);
foreach (DataRow rows in ds.Tables[0].Rows)
{
DateTime start = DateTime.Parse(lbsdate.Text);
DateTime end = DateTime.Parse(lbrdate.Text);
totdays = (end - start).Days;
if ((totdays >= 1) && (totdays <= 6) && (start.Month == 11) || (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3))
{
rent =
Convert.ToInt32(rows["2_6DaysLowSeason"].ToString());
}
}
tot = rent * totdays;
totRent2 = tot.ToString();//.....this is variable which i am using in inline code-----------------------
}