本文介绍了我的代码有问题..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据库表用户
id int
电子邮件varchar(5000)
名称varchar(500)
ImageName varchar(500)
mydatabase表Scrap
id int
ToId int
FromId int
消息varchar(5000)
SendDate datetime
在我的代码中,我将消息发送给了我的朋友
这是代码
my database table User
Id int
Email varchar(5000)
Name varchar(500)
ImageName varchar(500)
mydatabase table Scrap
Id int
ToId int
FromId int
Message varchar(5000)
SendDate datetime
in my code i send the message to my friend
this is code
<pre lang="midl">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());
<pre lang="xml"><div align="justify">
<%#DataBinder .Eval(Container.DataItem,"Message")%>
<br />
<br />
</div>
<span>Posted On: </span>
<asp:Label ID="lblSendDate" runat="server" Text=''<%# DataBinder.Eval(Container.DataItem,"SendDate") %>''></asp:Label>
这是在Gridview中显示消息的代码
Here is the code to display message in Gridview
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();
}
}
Now Problem is that is sendDate is not displayed how to i enter sendDate on which I SendMessage and display that data on Gridview
推荐答案
这篇关于我的代码有问题..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!