Click here to Skip to main content
15,905,073 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
<pre lang="xml"><asp:DataList ID="SearchResultList" runat="server" Width="100%" RepeatColumns="9" OnSelectedIndexChanged="SearchResultList_SelectedIndexChanged">
               <ItemTemplate>
                  <table border="0" cellpadding="2" cellspacing="2" align="center" style="background-color: #f5f5f5">
                      <tr>
                          <td align="center" valign="top">
                              <a href='<%#getHREF(Container.DataItem)%>'>
                                  <img src='<%#getSRC(Container.DataItem) %>' align="middle" border="0" width="80px">
                              </a>
                          </td>
                      </tr>
                  </table>
              </ItemTemplate>
              </asp:DataList>





if (!Page.IsPostBack)
      {
          GetSearchResult(Request.QueryString["searchText"].ToString());
      }
  }
  public void GetSearchResult(string searchText)
  {
      string GetSearchResult = "Select * FROM [User] where Name like '" + searchText+ "%'";
      dt = dbClass.ConnectDataBaseReturnDT(GetSearchResult);
      //if (dt.Rows.Count > 0)
      //{
          SearchResultList.DataSource = dt;
          SearchResultList.DataBind();
      //}
  }
  public string getHREF(object sURL)
  {
      DataRowView dRView = (DataRowView)sURL;
      string Id = dRView["Id"].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(@"~/UserImage/missing.jpg");
      }
      else
      {
          return ResolveUrl("~/UserImage/" + dRView["ImageName"].ToString());
      }
  }

WHY USE DATAROWVIEW? DATALIST ALREADY GET DATA FROM DATATABLE


WHAT IS DATAROWVIEW?


2) string SenderFriendId = ((HtmlInputHidden)e.Item.FindControl("hiddenId")).Value;WHAT THIS LINE DO?
Posted
Comments
Smithers-Jones 31-May-11 14:12pm    
The user aliomar2 is om56 in his newest disguise. Still trolling/spamming!
Sergey Alexandrovich Kryukov 31-May-11 15:29pm    
I would suggest a ban for both, even if they are different persons. We had enough of it.
--SA

In Fact, you don't need this. You just do like this

XML
<a href='<%#getHREF(Container.DataItem,"Id")%>'>
                                  <img src='<%#getSRC(Container.DataItem,"ImageName") %>' align="middle" border="0" width="80px">
                              </a>


And ur code behind function will look like this

public string getHREF(object id)
    {
        
        return ResolveUrl("~/UserDetails.aspx?Id=" + Id.toString());
    }
    public string getSRC(object img)
    {
        
        if (ImageName == "NoImage")
        {
            return ResolveUrl(@"~/UserImage/missing.jpg");
        }
        else
        {
            return ResolveUrl("~/UserImage/" + img.ToString());
        }
    }
 
Share this answer
 
v3
Comments
[no name] 31-May-11 9:54am    
plz tell me about what is object and Id.toString()
Kiran Sonawane 31-May-11 9:58am    
object takes any value (string integer....) so we need convert it into string
1.) DATAROWVIEW: Represents a customized view of a DataRow.
http://msdn.microsoft.com/en-us/library/k65s5xs3(v=VS.100).aspx[^]

2.) This line is retrieving the value from an HTML element which allows you to store information in a nonviewable control on the form.http://msdn.microsoft.com/en-us/library/system.data.datarowview.aspx[^]

Both of these are links to MSDN you should learn how to search for the answers by using Google or MSDN. (Google usually provides the MSDN links). Copying code and not understanding what it does is a dangerous practice, most of the people here are happy to help but the answers you seek are easily found if you put in a small amount of time.

You probably found this site through a search engine, try instead entering the methods in question, you can easily find what they do and how to use them. This is meant as friendly advice, not meant to insult or denigrate your question.
 
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