Click here to Skip to main content
15,907,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:DataList ID="dlstEmployees" runat="server" CellPadding="4"
        ForeColor="#333333" Width="233px">
    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
    <AlternatingItemStyle BackColor="White" />
    <ItemStyle BackColor="#E3EAEB" />
    <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<ItemTemplate>

  <%#DataBinder.Eval(Container.DataItem,"FirstName") %>
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/ViewDetails.aspx"
        Target="_search">View</asp:HyperLink>
</ItemTemplate>
</asp:DataList>


when i click to view i want to view that user profile ..(i.e want to retrieve sql(nt using sqldatasource) data in datalist(i mean i want to retrieve tat user information)


in veiw
Posted
Updated 12-Dec-11 0:00am
v2

Just pass user id as query string and then you can get user deatils from Sql and show in any control

NavigateUrl="~/ViewDetails.aspx?empid=10"
 
Share this answer
 
Comments
ythisbug 12-Dec-11 6:20am    
it showing error like "the server tag is not well formed" ?wat this mean
ythisbug 12-Dec-11 6:25am    
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["dbConnection"].ToString());
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_JoinRegistration";
cmd.Connection = con;
con.Open();

DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
dlstEmployees.DataSource = dt;
dlstEmployees.DataBind();

cmd.Dispose();
con.Close();
}
this coding i gave in page load..anything i left??is it correct?
ythisbug 12-Dec-11 6:26am    
ALTER PROCEDURE [dbo].[usp_JoinRegistration]
(@ID int output)
AS
BEGIN
SET NOCOUNT ON;

-- Insert statements for procedure here
SELECT Registration.FirstName,Registration.MiddleName,Registration.LastName,Registration.DateOfBirth,Registration.Gender,Registration.Email,Registration.Occupation,Registration.State,Registration.City,Registration.Nationality,Registration2.Address,Registration2.Company,Registration2.Relationship,Registration2.DateOfJoin,Registration2.Place
from Registration,Registration2
where Registration.ID=Registration2.ID
END


and this is stored procedure
You can use LinkButton instead of HyperLink otherwise if you want to use HyperLink then you have to use QueryString in HyperLink.
Through LinkButton
<asp:LinkButton id="LinkButton1" Text="View" CommandName="Dis" CommandArgument='<%#Eval("FirstName")%>'>

In CodeBehind file you have to create a function like this::::::::
protected void Display(object o, EventArgs e)
{
if(e.CommandName=="Dis")
{
Sql="Select * from TableName where FirstName='"+(e.CommandArgument).ToString()+"'";

-- Now write your further code here (Bind record) ------------
}
}
 
Share this answer
 
Comments
ythisbug 12-Dec-11 6:52am    
ok thanks..vil you tel me how to use here stored procedure??
ythisbug 13-Dec-11 5:18am    
any other solution for this??

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