本文介绍了有关databinder.Eval(Container.Dataitem,"Message")的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre lang="xml"><asp:TemplateField>
                       <ItemTemplate>
                           <table align="left" cellpadding="1" cellspacing="2">
                               <tr>
                                   <td>
                                       <a href=''<%#getUserHREF(Container.DataItem)%>''>
                                           <img align="middle" src=''<%#getSRC(Container.DataItem)%>'' border="0" width="50" /></a>
                                   </td>
                                   <td style="width: 7px">
                                       &nbsp;</td>
                               </tr>
                           </table>
                           <div align="justify">
                               <%#DataBinder.Eval(Container.DataItem, "Message")%>what this line what the container.dataitem do in this line?
                               <br />
                               <br />
                           </div>
                           <span>Posted On: &nbsp;</span>
                           <asp:Label ID="lblSendDate" runat="server" Text=''<%# DataBinder.Eval(Container.DataItem,"SendDate") %>''></asp:Label>
                       </ItemTemplate>
                   </asp:TemplateField>
               </Columns>







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();
       }
   }
   public string getUserHREF(object sURL)
   {
       DataRowView dRView = (DataRowView)sURL;
       string Id = dRView["UserId"].ToString();
       return ResolveUrl("~/UserDetails.aspx?Id=" + Id);




   }
   public string getSRC(object imgSRC)
   {
       DataRowView dRView = (DataRowView)imgSRC;
       string ImageName = dRView["ImageName"].ToString();
       if (ImageName == "NoImage")
       {
           return ResolveUrl(@"~/Site_Images/image_missing.jpg");
       }
       else
       {
           return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString());
       }
   }



Databinder.Eval(Container.Dataitem,"Message")在此代码中的作用



what Databinder.Eval(Container.Dataitem,"Message") do in this code

推荐答案

It will Bind Your DataBase Message Column Data to that Field of Gridview


这篇关于有关databinder.Eval(Container.Dataitem,"Message")的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:41