Want more features on Pastebin? Sign Up, it's FREE!
Guest

Error Code

By: a guest on Oct 17th, 2010  |  syntax: VB.NET  |  size: 4.65 KB  |  views: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Imports System.Data.SqlClient
  2.  
  3. Public Class _Default
  4.     Inherits System.Web.UI.Page
  5.  
  6.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  7.  
  8.  
  9.         'Dim objConn As New SqlConnection("Server=gebruiker-pc;Database=dbCarRental;Uid=sa; Pwd=empty;")
  10.  
  11.         'Dim objCmd As New SqlCommand("getAllCars", objConn)
  12.         'objCmd.Parameters.Add("@car_id", SqlDbType.Int).Value = 3
  13.  
  14.         'objCmd.CommandType = CommandType.StoredProcedure
  15.  
  16.         'objConn.Open()
  17.  
  18.         'Dim DR As SqlDataReader = objCmd.ExecuteReader()
  19.  
  20.         'DetailsView1.DataSource = DR
  21.  
  22.         'DetailsView1.DataBind()
  23.  
  24.         'DR.Close()
  25.  
  26.         'DR = Nothing
  27.  
  28.         'objCmd.Dispose()
  29.  
  30.         'objCmd = Nothing
  31.  
  32.         'objConn.Close()
  33.  
  34.         'objConn = Nothing
  35.  
  36.  
  37.         filldatagrid(Convert.ToInt32(CarGrid.Rows(0).Cells(1).Text))
  38.  
  39.         CarGrid.SelectedIndex = 0
  40.  
  41.     End Sub
  42.  
  43.  
  44.  
  45.     Protected Sub CarGrid_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CarGrid.SelectedIndexChanged
  46.         'MsgBox(CarGrid.SelectedRow.Cells(1).Text)
  47.  
  48.         filldatagrid(Convert.ToInt32(CarGrid.SelectedRow.Cells(1).Text))
  49.  
  50.     End Sub
  51.  
  52.  
  53.     Public Sub filldatagrid(ByVal id As Integer)
  54.         Dim objConn As New SqlConnection("Server=gebruiker-pc;Database=dbCarRental;Uid=sa; Pwd=empty;")
  55.  
  56.         Dim objCmd As New SqlCommand("getAllCars", objConn)
  57.         objCmd.Parameters.Add("@car_id", SqlDbType.Int).Value = id
  58.  
  59.         objCmd.CommandType = CommandType.StoredProcedure
  60.  
  61.         objConn.Open()
  62.  
  63.         Dim DR As SqlDataReader = objCmd.ExecuteReader()
  64.  
  65.         DetailsView1.DataSource = DR
  66.  
  67.         DetailsView1.DataBind()
  68.  
  69.         DR.Close()
  70.  
  71.         DR = Nothing
  72.  
  73.         objCmd.Dispose()
  74.  
  75.         objCmd = Nothing
  76.  
  77.         objConn.Close()
  78.  
  79.         objConn = Nothing
  80.  
  81.     End Sub
  82.  
  83.  
  84.     Private Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles DetailsView1.ItemInserting
  85.  
  86.  
  87.  
  88.         '         // Get Value from DropDown
  89.         'int TopicID = 0;
  90.         'foreach (DetailsViewRow row in ItemsDetailsView.Rows)
  91.         '{
  92.         '    if (row.Cells[0].Text == "Topic")
  93.         '    {
  94.         '         DropDownList TopicDropDown = (DropDownList)row.Cells[1].FindControl("Topic_TopicIDList");
  95.         '         TopicID = int.Parse(TopicDropDown.SelectedValue.ToString());
  96.         '    }
  97.  
  98.  
  99.         '}
  100.  
  101.         '    MsgBox(CType(DetailsView1.Rows(1).Cells(0).Controls(0), Label))
  102.  
  103.  
  104.  
  105.  
  106.         '    For Each row As DetailsViewRow In DetailsView1.Rows
  107.  
  108.         '        Dim cell1 As TableCell = row.Cells(1)
  109.  
  110.         '        Dim value1 As String
  111.  
  112.         '        value1 = cell1.Text
  113.  
  114.         '        MsgBox(value1)
  115.  
  116.  
  117.         '    Next
  118.  
  119.         '    Dim item As New DetailsViewItem(col.ColumnName, row(index).ToString(), col.DataType.ToString(), col.DefaultValue)
  120.         '  MsgBox(DetailsView1.Rows(1).Controls(0).)
  121.  
  122.  
  123.         '    MsgBox([Enum].GetValues)
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.         '    tb = DetailsView1.FindControl("Categorie")
  132.         '    s = tb.Text
  133.  
  134.         '    MsgBox(s.ToString)
  135.  
  136.         '    For Each dvr As DetailsViewRow In DetailsView1.Rows
  137.         '        If dvr.Cells.Count = 2 Then
  138.         '            If dvr.Cells(1).Controls.Count > 0 Then
  139.         '                Dim txt As TextBox
  140.         '                txt = dvr.Cells(1).Controls(0)
  141.         '                MsgBox("ID: " & txt.ID)
  142.         '                MsgBox("Text: " & txt.Text.ToString)
  143.         '            End If
  144.         '        End If
  145.         '    Next
  146.  
  147.         '    For i As Integer = 0 To e.Values.Count - 1
  148.         '        If e.Values(i) IsNot Nothing Then
  149.         '            e.Values(i) = Server.HtmlEncode(e.Values(i).ToString())
  150.         '            ' MsgBox(Server.HtmlEncode(e.Values(i).ToString()))
  151.  
  152.         '        End If
  153.         '    Next
  154.  
  155.  
  156.     End Sub
  157.  
  158.     Private Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles DetailsView1.ItemUpdating
  159.  
  160.  
  161.     End Sub
  162.  
  163.     Private Sub DetailsView1_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewModeEventArgs) Handles DetailsView1.ModeChanging
  164.         If (e.NewMode = DetailsViewMode.Insert) Then
  165.  
  166.             DetailsView1.ChangeMode(DetailsViewMode.Insert)
  167.  
  168.              
  169.         End If
  170.  
  171.    
  172.     End Sub
  173.  
  174.  
  175.    
  176.     Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs) Handles DetailsView1.PageIndexChanging
  177.  
  178.     End Sub
  179. End Class
clone this paste RAW Paste Data