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
----------------
<%# Eval("type") %>
<%# Eval("Amount") %>
2nd datalist
--------------
<%# Eval("type1") %>
<%# Eval("Amount1") %>
---------------------
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();
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.