Click here to Skip to main content
15,920,680 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
my table User

Id int

Email varchar(500)
Name varchar(500)


Scrap

Id int
FromId int
ToId int
Message varchar(5000)
SendDate datetime

GetUserScraps.aspx

XML
<div align="justify">
<%#DataBinder .Eval(Container.DataItem,"Message")%>
<br />
 <br />
</div>
<span>Posted On: &nbsp;</span>
<asp:Label ID="lblSendDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"SendDate") %>'></asp:Label>


This my front end code

C#
protected void ButtonPostScrap_Click(object sender, EventArgs e)
   {
       if (!object.Equals(Session["Id"], null))
       {
           string postScrap = "Insert INTO Scrap (FromId,ToId,Message) VALUES('" + Session["Id"].ToString() + "','" + Request.QueryString["Id"].ToString() + "','" + TextBoxScrap.Text + "')";
           dbClass.ConnectDataBaseToInsert(postScrap);
          Response.Redirect("UserDetails.aspx?Id=" + Request.QueryString["Id"].ToString());
       }


this is code for displaying in Grid
GetUserScraps.ascx


DataBaseClass dbClass = new DataBaseClass();
    public DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            GetUserScrap(int.Parse(Request.QueryString["Id"].ToString()));
        }
    }
    public void GetUserScrap(int Id)
    {
        string getUserScraps = "SELECT u.Id as UserId,u.Name,u.ImageName,s.FromId,s.ToId,s.Message,s.SendDate,s.ID as ScrapId FROM [User] as u, Scrap as s WHERE u.Id=s.FromId AND s.ToId='" + Request.QueryString["Id"].ToString() + "'";
        dt = dbClass.ConnectDataBaseReturnDT(getUserScraps);
        if (dt.Rows.Count > 0)
        {
            GridViewUserScraps.DataSource = dt;
            GridViewUserScraps.DataBind();
        }
    }


problem is that that how i display date when message is send how i bind it ?
when i insert the message i not insert the date

i only insert FromId,ToId,Message



plz regarding above code
Posted
Updated 3-Jun-11 0:43am
v2
Comments
ArtificerGM 8-Jun-11 17:12pm    
Ok, from what I understand you are NOT saving the Date-Sent but you want to recall it later. How does that work? Do you have a trigger that sets the current date when you save the record? Other than saving the date yourself there is no way of recalling it. It's kind of like going to bank to withdrawl money from an empty account. You're not going to get anything back unless its there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900