You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.9 KiB
83 lines
2.9 KiB
Imports Telerik.Web.UI
|
|
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlTypes
|
|
Imports Telerik
|
|
|
|
Public Class DiverseAbfragen
|
|
Inherits System.Web.UI.Page
|
|
|
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
If (Not IsPostBack) Then
|
|
'LoadData()
|
|
|
|
End If
|
|
|
|
'Me.SqlDataSource1.SelectCommand = "Select * from beruf"
|
|
'Me.RadGrid1.DataBind()
|
|
End Sub
|
|
|
|
Private Sub LoadData(ByVal sql As String)
|
|
Try
|
|
Dim dt As New DataTable
|
|
dt = GetDataTable(sql)
|
|
RadGrid1.DataSource = dt
|
|
RadGrid1.MasterTableView.Columns.Clear()
|
|
|
|
For Each c As DataColumn In dt.Columns
|
|
Dim c1 As New GridBoundColumn
|
|
RadGrid1.MasterTableView.Columns.Add(c1)
|
|
c1.DataField = c.ColumnName
|
|
c1.HeaderText = c.ColumnName
|
|
c1.ItemStyle.Wrap = False
|
|
Next
|
|
Me.RadGrid1.Rebind()
|
|
'RadGrid1.DataSource = GetDataTable("Select * from Firma")
|
|
'For Each c As GridColumn In RadGrid1.Columns
|
|
' c.HeaderStyle.Width = 20
|
|
'Next
|
|
'Me.RadGrid1.Rebind()
|
|
Catch ex As Exception
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
|
|
LoadData(RadComboBox1.SelectedValue)
|
|
End Sub
|
|
|
|
Private Sub RadGrid1_PageIndexChanged(ByVal source As Object, ByVal e As GridPageChangedEventArgs) Handles RadGrid1.PageIndexChanged
|
|
LoadData(RadComboBox1.SelectedValue)
|
|
End Sub
|
|
|
|
Protected Sub RadGrid1_PageSizeChanged(ByVal source As Object, ByVal e As Web.UI.GridPageSizeChangedEventArgs) Handles RadGrid1.PageSizeChanged
|
|
LoadData(RadComboBox1.SelectedValue)
|
|
End Sub
|
|
|
|
Private Sub RadGrid1_PreRender(sender As Object, e As System.EventArgs) Handles RadGrid1.PreRender
|
|
|
|
End Sub
|
|
|
|
Private Sub RadGrid1_SortCommand(ByVal source As Object, ByVal e As GridSortCommandEventArgs) Handles RadGrid1.SortCommand
|
|
LoadData(RadComboBox1.SelectedValue)
|
|
End Sub
|
|
|
|
Public Function GetDataTable(ByVal query As String) As DataTable
|
|
Dim ConnString As String = ConfigurationManager.ConnectionStrings("LPConnectionString").ConnectionString
|
|
Dim conn As SqlConnection = New SqlConnection(ConnString)
|
|
Dim adapter As SqlDataAdapter = New SqlDataAdapter
|
|
adapter.SelectCommand = New SqlCommand(query, conn)
|
|
Dim table1 As New DataTable
|
|
conn.Open()
|
|
Try
|
|
adapter.Fill(table1)
|
|
Finally
|
|
conn.Close()
|
|
End Try
|
|
Return table1
|
|
End Function
|
|
|
|
Protected Sub RadComboBox1_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
|
|
If RadComboBox1.SelectedItem IsNot Nothing Then
|
|
LoadData(RadComboBox1.SelectedValue)
|
|
End If
|
|
End Sub
|
|
End Class |