i am having two logins,one login for employee and another login for hr,hr wants to create the payslip for every month,if the HR created the payslip for the particular employee,once created the payslip,the employee can login in his account ,if payslip is created it will be displayed in the gridview,in that gridview i provide a print option,,,and pass the employee id using the eval..my problem is,,if the particulare employee having the payslips details in the gridview,it will be order by month wise,if the user wants to take the print,if the employee want to take the print for the month of february,,when the employee clicks the print option by mistake january month record is printed,,i need to print februry as per the employee selection,,,this is my code,
form1.aspx
in gridview all the months of salary details will be displayed,
<Columns>
<asp:BoundField DataField="empcode" HeaderText="Employee Code"
SortExpression="empid" />
<asp:BoundField DataField="empname" HeaderText="Employee Name"
SortExpression="empname" />
<asp:BoundField DataField="month" HeaderText="Month" SortExpression="month" />
<asp:BoundField DataField="year" HeaderText="Year" SortExpression="year" />
<asp:BoundField DataField="totsal" HeaderText="totsal" SortExpression="totsal" />
<asp:BoundField DataField="netpayable" HeaderText="Net Payable"
SortExpression="netpayable" />
<asp:TemplateField HeaderText="Print">
<ItemTemplate>
<asp:LinkButton ID="lb" runat="server"
PostBackUrl='<%# "printpayslip.aspx?empcode=" + Eval("empcode").tostring() %>'
Text="Print"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
printpayslip.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connection As New SqlConnection
Dim cmd As New SqlCommand
Dim dt As New DataTable
Dim da As New SqlDataAdapter
connection.ConnectionString = ("Data Source=RIFAYEE-PC;Initial Catalog=OpalAsia;Integrated Security=True")
If Not Page.IsPostBack Then
Dim empcode As [String] = Request.QueryString("empcode")
'If empid = "" Then
'Response.Write("Invalid Employee ID")
'Return
'End If
cmd = New SqlCommand("select * from payslip where empcode='" + empcode + "'", connection)
da = New SqlDataAdapter(cmd)
dt.Clear()
da.Fill(dt)
If dt.Rows.Count > 0 Then
Label4.Text = empcode
Label3.Text = dt.Rows(0)(1).ToString()
Label2.Text = dt.Rows(0)(5).ToString
Label37.Text = dt.Rows(0)(6).ToString
Label10.Text = dt.Rows(0)(7).ToString
Label36.Text = dt.Rows(0)(9).ToString
Label8.Text = dt.Rows(0)(10).ToString
Label10.Text = dt.Rows(0)(16).ToString
Label11.Text = dt.Rows(0)(32).ToString
Label13.Text = dt.Rows(0)(17).ToString
Label18.Text = dt.Rows(0)(18).ToString
Label14.Text = dt.Rows(0)(19).ToString
Label19.Text = dt.Rows(0)(19).ToString
Label15.Text = dt.Rows(0)(20).ToString
Label20.Text = dt.Rows(0)(20).ToString
Label16.Text = dt.Rows(0)(21).ToString
Label21.Text = dt.Rows(0)(21).ToString
Label17.Text = dt.Rows(0)(22).ToString
Label22.Text = dt.Rows(0)(22).ToString
Label23.Text = dt.Rows(0)(23).ToString
Label26.Text = dt.Rows(0)(26).ToString
Label27.Text = dt.Rows(0)(24).ToString
Label28.Text = dt.Rows(0)(25).ToString
Label29.Text = dt.Rows(0)(26).ToString
Label30.Text = dt.Rows(0)(27).ToString
Label31.Text = dt.Rows(0)(29).ToString
Label32.Text = dt.Rows(0)(30).ToString
Label33.Text = dt.Rows(0)(31).ToString
Label34.Text = dt.Rows(0)(32).ToString
Label35.Text = dt.Rows(0)(35).ToString
Label24.Text = dt.Rows(0)(24).ToString
Label25.Text = dt.Rows(0)(25).ToString
Label24.Text = dt.Rows(0)(15).ToString
Label25.Text = dt.Rows(0)(15).ToString
Label12.Text = dt.Rows(0)(33).ToString
End If
End If
End Sub