Forum guidelines
AuthorQuestion
concatanation in datalist asp.net c#
Posted By yadagiri uppari on 29 Jun 2013
hi sir....I have datalist in which i am displaying data which is entered in textbox when send button ckicked...when send button clicked then i am storing data into db and binding from there into datalist......it is overwritten by recent data...how to concatenate previous data in datalist..pls help me sir
AuthorReply
Re: concatanation in datalist asp.net c#
Posted By Kunal Vaishya on 01 Jul 2013  
Hi,
You can use page code backround Static List<> or DataSet at the Time of Concating Merger data with List or DataSet and Just Display to DataList.

kingskunal If this post is useful then mark it as "Accepted Answer"
Re: concatanation in datalist asp.net c#
Posted By yadagiri uppari on 01 Jul 2013  
pls tell me sir how to do that..........please i am new to asp.net
please provide code sir

Re: concatanation in datalist asp.net c#
Posted By yadagiri uppari on 01 Jul 2013  

sir this is my code...please refer and provide solution to me..
codebehind:
 protected void btnSend_Click(object sender, EventArgs e)
    {
        try
        {
            //GetImages();

            SqlParameter param1 = new SqlParameter("@senderid", Session["sender"]);
            SqlParameter param2 = new SqlParameter("@message", Session["txtMessage"]);
            SqlParameter param3 = new SqlParameter("@date", DateTime.Now);
            SqlParameter param7 = new SqlParameter("@receiverid", Session["receiver"]);
            String stm = "sp_ChatInsert";
            SqlHelper.ExecuteNonQuery(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, stm, param1, param2, param3, param7);
            getMessage();
            //txtCompose.Text = null;
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
 public void getMessage()
    {
        try
        {
            
            string strSql = "sp_GetChatMessage";
            //string curChatHistory = null;
            SqlParameter param5 = new SqlParameter("@senderid", Session["sender"]);
            SqlParameter param6 = new SqlParameter("@receiverid", Session["receiver"]);
           
            ds = SqlHelper.ExecuteDataset(CommonSetting.GetConnectionString(true), CommandType.StoredProcedure, strSql, param5, param6);
            dldisplayMessage.DataSource = ds;
            //List<string> strrr = new List<string>();
            //foreach (DataRow dr in ds.Tables[0].Rows)
            //{
            //    strrr.Add(dr["SenderId"].ToString());
            //    strrr.Add(dr["Message"].ToString());
            //    strrr.Add(dr["Date"].ToString());
            //    if (Session["curr"] != null)
            //    {
            //        strrr.Add(Session["curr"].ToString());
            //    }
            //}
            //curChatHistory = curChatHistory + ds.Tables[0].Rows[0]["SenderID"].ToString() + "<html>" + ds.Tables[0].Rows[0]["Message"].ToString() + "</html>" + ds.Tables[0].Rows[0]["Date"].ToString() + "<br>";
            //ViewState["curChatHistory"] = curChatHistory;
       
            //Session["curr"]= strrr;

            //List<string> strrr1 = new List<string>();
            //strrr1 = null;
           // strrr1 += strrr;


            //dldisplayMessage.DataSource = Session["curr"];

           // AjaxControlToolkit.HTMLEditor.Toolbar test = (AjaxControlToolkit.HTMLEditor.Toolbar)FTBMessage.Controls[0].Controls[2].Controls[0].Controls[0];
            dldisplayMessage.DataBind();
            

SPONSORED BY

Custom Software Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.