Forum
Sayfamda Bir Adet Menü ve Bir Adet Datalist Var. load event şu şekilde Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then PopulateMenu() End If Menüyü Şu Kodlarla Dolduruyorum : Private Sub PopulateMenu() Dim menuData As DataTable = GetMenuData() AddTopMenuItems(menuData) End Sub Private Function GetMenuData() As DataTable Dim selectCommand As String = "SELECT CategoryId,ParentId,Name FROM Categories" Dim conString As String = WebConfigurationManager.ConnectionStrings("sqldata").ConnectionString Dim dad As SqlDataAdapter = New SqlDataAdapter(selectCommand, conString) Dim dtblCategories As DataTable = New DataTable() dad.Fill(dtblCategories) Return dtblCategories End Function Private Sub AddTopMenuItems(ByVal menuData As DataTable) Dim view As DataView = New DataView(menuData) view.RowFilter = "ParentID IS NULL" Dim row As DataRowView For Each row In view Dim NewMenuItem As MenuItem = New MenuItem(row("Name").ToString(), row("CategoryId").ToString()) Menu1.Items.Add(NewMenuItem) AddChildMenuItems(menuData, NewMenuItem) Next End Sub Private Sub AddChildMenuItems(ByVal menuData As DataTable, ByVal parentMenuItem As MenuItem) Dim view As DataView = New DataView(menuData) view.RowFilter = "ParentID=" + parentMenuItem.Value Dim row As DataRowView For Each row In view Dim NewMenuItem As MenuItem = New MenuItem(row("Name").ToString(), row("CategoryId").ToString()) parentMenuItem.ChildItems.Add(NewMenuItem) AddChildMenuItems(menuData, NewMenuItem) Next End Sub Datalisti şu Kodlarla Dolduruyorum : Private Sub Yukle() Try Sayfa = New PagedDataSource Dim DataTable As New DataTable Baglanti = New SqlConnection Baglanti.ConnectionString = "Data Source=72.72.72.72;Initial Catalog=deneme;Persist Security Info=True;User ID=deneme;Password=deneme" If Baglanti.State = ConnectionState.Closed Then Baglanti.Open() command = New SqlCommand command.Connection = Baglanti command.CommandText = "SELECT * FROM Products where CategoryId=@CategoryId" command.Parameters.AddWithValue("@CategoryId", Menu1.SelectedValue) rs.Fill(DataTable) Baglanti.Close() Sayfa.DataSource = DataTable.DefaultView Sayfa.AllowPaging = True Sayfa.PageSize = 6 SayfaSayisi = Sayfa.PageCount - 1 Sayfa.CurrentPageIndex = SayfaNo dtlist.DataSource = Sayfa ReadSayfa() Catch ex As Exception Baglanti.Close() End Try End Sub Sorun Şu :
Mrb
debug yapıp detay verir misiniz ..
çözümsüz..