Converting this Code to C#
I am trying to use this code from VB to C#..I tried to converting it but i get an Function error? can anyone please help me?
Private Sub Datalist1_ItemCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles Datalist1.ItemCommand
If e.CommandName = "Show" Then
Dim EmpIDlabel As Label = e.Item.FindControl("lblEID")
Dim strEmpID As String = EmpIDlabel.Text
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataSource = GetEmpDetails(strEmpID)
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataBind()
CType(e.Item.FindControl("Datagrid1"), DataGrid).Visible = True
CType(e.Item.FindControl("btnDetails"), LinkButton).Text = "-"
CType(e.Item.FindControl("btnDetails"), LinkButton).CommandName = "Hide"
End If
If e.CommandName = "Hide" Then
CType(e.Item.FindControl("Datagrid1"), DataGrid).Visible = False
CType(e.Item.FindControl("btnDetails"), LinkButton).Text = "+"
CType(e.Item.FindControl("btnDetails"), LinkButton).CommandName = "Show"
End If
End Sub
Function GetEmpDetails(ByVal Employeeid As String) As SqlDataReader
Const strConnString As String = "server=localhost;uid=sa;pwd=;database=northwind"
Dim objConn As New SqlConnection(strConnString)
Dim strSQL As String
strSQL = "SELECT FirstName , LastName ,Title, Address FROM Employees " & _
"WHERE Employeeid = @Employeeid"
Dim objCmd As New SqlCommand(strSQL, objConn)
Dim paramEmployeeid As SqlParameter
paramEmployeeid = New SqlParameter("@Employeeid", SqlDbType.VarChar, 10)
paramEmployeeid.Value = Employeeid
objCmd.Parameters.Add(paramEmployeeid)
objConn.Open() 'Open the connection
Return objCmd.ExecuteReader(CommandBehavior.CloseConnection)
End Function