Harish Batchu

Harish Batchu

  • NA
  • 255
  • 69.7k

When loading data into datalist it's not loading?

Nov 13 2018 10:48 PM
 
 
 Problem
------------
 
       I have two datalist on one page the both are in different div tags. I need to load 2 datalist on page load but when i loading data into datalist i am getting data form 1st datalist but i am not getting data for 2nd list. I have tired diffrent ways and check id's for datalist and column id.
 
 
Pls give me solutionn as early as possible 
 
 
 
 
 
1st datalist
----------------
<asp:DataList ID="IncomeList" runat="server" Style="width: 100%; border-collapse: collapse;">
<ItemTemplate>
<hr class="light-grey-hr row mt-10 mb-15" />
<div class="label-chatrs">
<div class="">
<span class="clabels-text font-12 inline-block txt-dark capitalize-font pull-left"><span class="block font-15 weight-500 mb-5"><%# Eval("type") %></span><span class="block txt-grey">&nbsp;</span></span>
<div class="pull-right"><span class="txt-primary font-18 weight-600"><%# Eval("Amount") %></span></div>
<div class="clearfix"></div>
</div>
</div>
</ItemTemplate>
 
 
</asp:DataList>
2nd datalist
-------------- 
 
<asp:DataList ID="ExpenceList" runat="server" Style="width: 100%; border-collapse: collapse;">
<ItemTemplate>
<hr class="light-grey-hr row mt-10 mb-15" />
<div class="label-chatrs">
<div class="">
<span class="clabels-text font-12 inline-block txt-dark capitalize-font pull-left"><span class="block font-15 weight-500 mb-5"><%# Eval("type1") %></span><span class="block txt-grey">&nbsp;</span></span>
<div class="pull-right"><span class="txt-primary font-18 weight-600"><%# Eval("Amount1") %></span></div>
<div class="clearfix"></div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
 
 backend coding
---------------------
public void GetIncome()
{
con = u.GetConnection();
string uniq=Session["userUniq"].ToString();
string QueryString = "select top(3) IncomeType as type,UserIncomeDetail_Amount as Amount from ft_UserIncomeDetail inner join Dim_IncomeType on ft_UserIncomeDetail.IncomeType_Id=Dim_IncomeType.IncomeType_id where MONTH(UserIncomeDetail_Date) = MONTH(GETDATE()) and ft_UserIncomeDetail.User_Uniq='"+uniq+"'";
cmd = new SqlCommand(QueryString, con);
cmd.CommandType = CommandType.Text;
dr= cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
IncomeList.DataSource = dr;
IncomeList.DataBind();
dr.Close();
con.Close();
}
}
//get Top Three Expeness Details
public void GetExpencess()
{
SqlDataReader dr1;
con = u.GetConnection();
string uniq = Session["userUniq"].ToString();
// string Query = "select top(3) IncomeType as type,UserIncomeDetail_Amount as Amount from ft_UserIncomeDetail inner join Dim_IncomeType on ft_UserIncomeDetail.IncomeType_Id=Dim_IncomeType.IncomeType_id where MONTH(UserIncomeDetail_Date) = MONTH(GETDATE()) and ft_UserIncomeDetail.User_Uniq='" + uniq + "'";
string Query = "select top(3) de.ExpenceType as type1,ed.UserExpenceDetail_Amount as Amount1 from ft_UserExpenceDetail ed inner join Dim_ExpenceType de on de.UserExpencedetailType_id=ed.UserExpenceDetail_Id where MONTH(ed.UserExpenceDetail_Date) = MONTH(GETDATE()) and ed.User_Uniq='" + uniq + "'";
cmd = new SqlCommand(Query, con);
cmd.CommandType = CommandType.Text;
dr1 = cmd.ExecuteReader();
if (dr1.HasRows)
{
dr1.Read();
string s = dr1["type1"].ToString();
string s1 = dr1["Amount1"].ToString();
ExpenceList.DataSource = dr1;
ExpenceList.DataBind();
dr1.Close();
con.Close();
}
}