i have some data in a Gridview....

May 13 2010 11:34 PM
i have some data in a Gridview and in that there is a HyperLink field and when user click on that link i have to see respective data of that ID in a new  linked page. I am sending my .aspxpage and code-behind page.if possible please help me out...

<Columns>
     
            <asp:HyperLinkField DataNavigateUrlFields="Ecode,EmployeeName,Designation,Location"
             DataNavigateUrlFormatString="UpdatePage.aspx?ECODE={0}&amp;ENAME={1}&;DESIGNATION={2}&;LOCATION={3}"
             Text="clickToUpdatePage" />

<asp:TemplateField HeaderText="ECODE" Visible="true">
            <ItemTemplate>
            <asp:Label ID="LABELCODE" runat="server" Text='<%# Eval("ECODE") %>'></asp:Label>
            </ItemTemplate>          
            </asp:TemplateField>
</Columns>


code-behind page:-

public partial class EmpFetch : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
            
        
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        Library lib = new Library();
        string sEmp_name = empname.Text;
        DataTable dtEmpDetail = new DataTable();
        dtEmpDetail = lib.GetEmpInfo(sEmp_name);
        if (dtEmpDetail.Rows.Count > 0)
        {
            grdJobHistory.DataSource = dtEmpDetail;
            grdJobHistory.DataBind();
        }


    }
    protected void grdJobHistory_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        Library lib = new Library();
        string sEmp_name = empname.Text;
        DataTable dtEmpDetail = new DataTable();
        dtEmpDetail = lib.GetEmpInfo(sEmp_name);


        if (dtEmpDetail.Rows.Count > 0)
        {
            grdJobHistory.PageIndex = e.NewPageIndex;
            grdJobHistory.DataSource = dtEmpDetail;
            grdJobHistory.DataBind();
        }
        

    }


Answers (3)