Click here to Skip to main content
15,905,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi!
i am developing a website. i have two tables in my database. table1=username,email
table2= userage,pictuer.
what i want is to show all the users picture in a gridview/listview with a link named profile. when i user click on that profile link it redirects to another page and shows the user profile from table1 and table2.
please tell me how is it possible
thanks in advance
Posted

I do it in this way..The left most column named Course No acts as a link here and DataNavigateUrlFormatString here redirects user to your defined page.I hope it helps you..
XML
<asp:GridView ID="GridView1" CssClass="listStyle" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="courseNo">

        <Columns>

            <asp:HyperLinkField HeaderText="Course No" DataNavigateUrlFields="courseNo" DataNavigateUrlFormatString="~/Editing.aspx?courseNo={0}"
             DataTextField="courseNo" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6" />

            <asp:BoundField DataField="courseTitle" HeaderText="Course Title" HeaderStyle-ForeColor="Maroon" HeaderStyle-BackColor="#ffb8a6"
                SortExpression="courseTitle"  ReadOnly="True"/>

        </Columns>
    </asp:GridView>
 
Share this answer
 
Comments
Abdul Quader Mamun 16-Aug-12 5:22am    
go Ahead.
You can use like this


XML
<asp:TemplateField HeaderText="Vch/Bill No">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval ("vch") %>' OnClick="LinkButton1_Click"></asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="100px" Height="20px" />
                                <HeaderStyle CssClass="headerstylelist" HorizontalAlign="Center"  />
                         </asp:TemplateField>





and in c#


C#
protected void LinkButton1_Click(object sender, EventArgs e)
   {
       LinkButton link = (LinkButton)sender;
       GridViewRow gv = (GridViewRow)(link.Parent.Parent);
       LinkButton CustomerID = (LinkButton)gv.FindControl("LinkButton1");
       Session["vchbill"] = CustomerID.Text;
       Label lbldate = (Label)gv.FindControl("date");
       Label lblparty = (Label)gv.FindControl("party");
       Label lblid = (Label)gv.FindControl("idlbl");
       Session["date"] = lbldate.Text;
       Session["party"] = lblparty.Text;

       SqlCommand cmd = new SqlCommand("select voucher from saleitemdata where vch='" + CustomerID.Text + "' and companyname='" + HiddenField1.Value + "'", con);
       dr = cmd.ExecuteReader();
       if (dr.Read())
       {
           lblid.Text = dr[0].ToString();
           Session["id"] = lblid.Text;
       } dr.Close();
       this.ClientScript.RegisterClientScriptBlock(this.GetType(), "close", "window.opener.location.href='saleitemvoucherbill.aspx', window.close()", true);


       //Response.Write("<script language='javascript'> { window.close();}</script>");
   }


beacuse from this you can send session in new page
 
Share this answer
 
v2
 
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