I have a stored procedure that contains 3 select queries.In C# code I have called this stored procedure and the result is stored in a dataset. In aspx form I have used repeater control and in that there are controls to which the result should be binded. But only the first variable i.e, "question" is binded and other two are not.
-------------------------------------------------------------------------------
Stored procedure code:
-------------------------------------------------------------------------------
CREATE PROCEDURE Sp_GetUserStat
@RegId int
AS
SELECT COUNT(*) AS question FROM tblQuestion WHERE RegID=@RegId ;
SELECT COUNT(*) AS answer FROM tblAnswer WHERE RegID=@RegId;
SELECT Points AS point FROM tblPoints WHERE RegID=@RegId;
RETURN 0
-------------------------------------------------------------------------------
C# code : GetUserStat(LogicLayer li)
-------------------------------------------------------------------------------
public DataSet GetUserStat(LogicLayer li)
{
try
{
cmd = new SqlCommand("Sp_GetUserStat", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@RegId", li.RegId);
adp = new SqlDataAdapter(cmd);
ds = new DataSet();
adp.Fill(ds, "UserStat");
return ds;
}
catch (Exception)
{
throw;
}
finally
{
cmd.Dispose();
}
}
-------------------------------------------------------------------------------
C# code : Get_UserStat(LogicLayer li)
-------------------------------------------------------------------------------
public DataSet Get_UserStat(LogicLayer li)
{
return dal.GetUserStat(li);
}
-------------------------------------------------------------------------------
C# code : CodeBehind
-------------------------------------------------------------------------------
public partial class UserProfile : System.Web.UI.Page
{
LogicLayer li = new LogicLayer();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
li.RegId = Convert.ToInt32(Session["RegId"]);
lstUserProfile.DataSource = li.Get_User_Profile(li);
lstUserProfile.DataBind();
rptUserStat.DataSource = li.Get_UserStat(li);
rptUserStat.DataBind();
}
}
}
------------------------------------------------------
ASPX code:
------------------------------------------------------
<asp:Repeater ID="rptUserStat" runat="server" >
<ItemTemplate>
<div class="ul_list ul_list-icon-ok">
<ul>
<li><i class="icon-question-sign"></i><a href="user_questions.html">Questions<span> ( <span><%#Eval("question")==null?"0":Eval("question") %></span> ) </span></a></li>
<li><i class="icon-comment"></i><a href="user_answers.html">Answers<span> ( <span><%#Eval("answer")==null?"0":Eval("answer") %></span> ) </span></a></li>
<%----%>
<li><i class="icon-heart"></i><a href="user_points.html">Points<span> ( <span><%----%></span> ) </span></a></li>
<%----%>
</ul>
</div>
</ItemTemplate>
</asp:Repeater>
What I have tried:
I have tried to Bind using DataBinder.Eval(Container.DataItem,"variable") but did not work.