Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<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());
       }
   }


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

1 solution

This method is particularly useful when binding data to controls that are in a templated list.
It will Bind Your DataBase Message Column Data to that Field of Gridview
 
Share this answer
 

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



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