nickmollberg
Programmer
Fame! Glory! Prizes!
Well, ok... none of those things, but I will be very grateful.
I need to convert the code below from vb into c#...
I'm trying to do it manually, but some of the syntax is tripping me up.
Is there a way to do this easily?
Sub BindTitle()
Dim ds As New DataSet
Dim sqlStmt As String = "SELECT * FROM Appt"
Dim conString As String = "server=cluster-sql;database=XCS_HciDev;uid=sa;pwd=pass;"
Dim myda As SqlDataAdapter = New SqlDataAdapter(sqlStmt, conString)
myda.Fill(ds, "Table")
Dim slist As SortedList = New SortedList
Dim i As Integer
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
If Not slist.ContainsValue(dr("UserId")) Then
slist.Add(dr("ApptSys"), dr("UserId"))
End If
Next
DataList1.DataSource = slist.GetValueList
DataList1.DataBind()
End Sub
Function getEmp(ByVal UserId As String) As DataSet
Dim ds As New DataSet
Dim sqlStmt As String = "SELECT * FROM Appt where UserId=" & "'" & UserId & "'"
Dim conString As String = "server=cluster-sql;database=XCS_HciDev;uid=sa;pwd=pass;"
Dim myda As SqlDataAdapter = New SqlDataAdapter(sqlStmt, conString)
myda.Fill(ds, "Table")
Return ds
End Function
Private Sub DataList1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
Dim Titlelabel As Label = e.Item.FindControl("lblETitle")
Dim strEmpTitle As String = Titlelabel.Text
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataSource = getEmp(strEmpTitle)
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataBind()
End Sub
Well, ok... none of those things, but I will be very grateful.
I need to convert the code below from vb into c#...
I'm trying to do it manually, but some of the syntax is tripping me up.
Is there a way to do this easily?
Sub BindTitle()
Dim ds As New DataSet
Dim sqlStmt As String = "SELECT * FROM Appt"
Dim conString As String = "server=cluster-sql;database=XCS_HciDev;uid=sa;pwd=pass;"
Dim myda As SqlDataAdapter = New SqlDataAdapter(sqlStmt, conString)
myda.Fill(ds, "Table")
Dim slist As SortedList = New SortedList
Dim i As Integer
Dim dr As DataRow
For Each dr In ds.Tables(0).Rows
If Not slist.ContainsValue(dr("UserId")) Then
slist.Add(dr("ApptSys"), dr("UserId"))
End If
Next
DataList1.DataSource = slist.GetValueList
DataList1.DataBind()
End Sub
Function getEmp(ByVal UserId As String) As DataSet
Dim ds As New DataSet
Dim sqlStmt As String = "SELECT * FROM Appt where UserId=" & "'" & UserId & "'"
Dim conString As String = "server=cluster-sql;database=XCS_HciDev;uid=sa;pwd=pass;"
Dim myda As SqlDataAdapter = New SqlDataAdapter(sqlStmt, conString)
myda.Fill(ds, "Table")
Return ds
End Function
Private Sub DataList1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataList1.ItemDataBound
Dim Titlelabel As Label = e.Item.FindControl("lblETitle")
Dim strEmpTitle As String = Titlelabel.Text
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataSource = getEmp(strEmpTitle)
CType(e.Item.FindControl("Datagrid1"), DataGrid).DataBind()
End Sub