Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. FormView Issue

FormView Issue

Scheduled Pinned Locked Moved ASP.NET
databasehelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cisco2103
    wrote on last edited by
    #1

    I am creating a golf Application to keep track of my stats and I am using a formview. Is there a better way to do this... Private Sub GetPutts() Dim txtPuttOne As TextBox = Me.FormView1.FindControl("txtPuttsHoleOne") Dim intPuttOne As Integer = CInt(txtPuttOne.Text) Dim txtPuttTwo As TextBox = Me.FormView1.FindControl("txtPuttsHoleTwo") Dim intPutttwo As Integer = CInt(txtPuttTwo.Text) Dim txtPuttThree As TextBox = Me.FormView1.FindControl("txtPuttsHoleThree") Dim intPuttThree As Integer = CInt(txtPuttThree.Text) Dim txtPuttFour As TextBox = Me.FormView1.FindControl("txtPuttsHoleFour") Dim intPuttFour As Integer = CInt(txtPuttFour.Text) Dim txtPuttFive As TextBox = Me.FormView1.FindControl("txtPuttsHoleFive") ***all the way to Hole 18 Try dsPutts.InsertCommand = "INSERT INTO [dbo].[Putt_Info] " dsPutts.InsertCommand += "([CourseId] ,[UserId],[ScoreID],[PuttsHoleOne]," dsPutts.InsertCommand += "[PuttsHoleTwo],[PuttsHoleThree],[PuttsHoleFour]," dsPutts.InsertCommand += "[PuttsHoleFive],[PuttsHoleSix] ,[PuttsHoleSeven]," dsPutts.InsertCommand += "[PuttsHoleEight],[PuttsHoleNine],[PuttsHoleTen]," dsPutts.InsertCommand += "[PuttsHoleEleven],[PuttsHoleTwelve],[PuttsHoleThirteen]," dsPutts.InsertCommand += "[PuttsHoleFourteen],[PuttsHoleFifteen],[PuttsHoleSixteen]," dsPutts.InsertCommand += "[PuttsHoleSeventeen] ,[PuttsHoleEighteen])" dsPutts.InsertCommand += "VALUES('" & courseID & "', '" & Session("UserName") & "', '" dsPutts.InsertCommand += Session("ScoreID") & "'," & intPuttOne & "," & intPutttwo & "," & intPuttThree & "," & intPuttFour & "," & intPuttFive & "," & intPuttSix & "," & intPuttSeven dsPutts.InsertCommand += "," & intPuttEight & "," & intPuttNine & "," & intPuttTen & "," & intPuttEleven & "," & intPuttTwelve & "," & intPuttThirteen dsPutts.InsertCommand += "," & intPuttFourteen & "," & intPuttFifteen & "," & intPuttSixteen & "," & intPuttSevenTeen & "," & intPuttEighteen & ")" dsPutts.InsertCommandType = SqlDataSourceCommandType.Text dsPutts.Insert() Catch ex As Exception Response.Write(ex) End Try End Sub I basically just want to grab the text the user enters in each of the controls and then insert it into the database. Thanks in advance

    C 1 Reply Last reply
    0
    • C cisco2103

      I am creating a golf Application to keep track of my stats and I am using a formview. Is there a better way to do this... Private Sub GetPutts() Dim txtPuttOne As TextBox = Me.FormView1.FindControl("txtPuttsHoleOne") Dim intPuttOne As Integer = CInt(txtPuttOne.Text) Dim txtPuttTwo As TextBox = Me.FormView1.FindControl("txtPuttsHoleTwo") Dim intPutttwo As Integer = CInt(txtPuttTwo.Text) Dim txtPuttThree As TextBox = Me.FormView1.FindControl("txtPuttsHoleThree") Dim intPuttThree As Integer = CInt(txtPuttThree.Text) Dim txtPuttFour As TextBox = Me.FormView1.FindControl("txtPuttsHoleFour") Dim intPuttFour As Integer = CInt(txtPuttFour.Text) Dim txtPuttFive As TextBox = Me.FormView1.FindControl("txtPuttsHoleFive") ***all the way to Hole 18 Try dsPutts.InsertCommand = "INSERT INTO [dbo].[Putt_Info] " dsPutts.InsertCommand += "([CourseId] ,[UserId],[ScoreID],[PuttsHoleOne]," dsPutts.InsertCommand += "[PuttsHoleTwo],[PuttsHoleThree],[PuttsHoleFour]," dsPutts.InsertCommand += "[PuttsHoleFive],[PuttsHoleSix] ,[PuttsHoleSeven]," dsPutts.InsertCommand += "[PuttsHoleEight],[PuttsHoleNine],[PuttsHoleTen]," dsPutts.InsertCommand += "[PuttsHoleEleven],[PuttsHoleTwelve],[PuttsHoleThirteen]," dsPutts.InsertCommand += "[PuttsHoleFourteen],[PuttsHoleFifteen],[PuttsHoleSixteen]," dsPutts.InsertCommand += "[PuttsHoleSeventeen] ,[PuttsHoleEighteen])" dsPutts.InsertCommand += "VALUES('" & courseID & "', '" & Session("UserName") & "', '" dsPutts.InsertCommand += Session("ScoreID") & "'," & intPuttOne & "," & intPutttwo & "," & intPuttThree & "," & intPuttFour & "," & intPuttFive & "," & intPuttSix & "," & intPuttSeven dsPutts.InsertCommand += "," & intPuttEight & "," & intPuttNine & "," & intPuttTen & "," & intPuttEleven & "," & intPuttTwelve & "," & intPuttThirteen dsPutts.InsertCommand += "," & intPuttFourteen & "," & intPuttFifteen & "," & intPuttSixteen & "," & intPuttSevenTeen & "," & intPuttEighteen & ")" dsPutts.InsertCommandType = SqlDataSourceCommandType.Text dsPutts.Insert() Catch ex As Exception Response.Write(ex) End Try End Sub I basically just want to grab the text the user enters in each of the controls and then insert it into the database. Thanks in advance

      C Offline
      C Offline
      chathu03j
      wrote on last edited by
      #2

      well, if u r using VS.NET 2005 u can do it in a very simple way by using an SqlDataSource object. You can configure the SqlDataSource object by appropriately selecting the server name, the database and the table u want to add the data. Then it automatically generates the SELECT,INSERT,UPDATE,DELETE statements or u can use ur own stored Procedures to do them. then drag n drop a formview on to the application and set it's datasource to SqlDataSource. e.g: FormView1.DataSource = SqlDataSource1; FormView1.DataBind();

      C 1 Reply Last reply
      0
      • C chathu03j

        well, if u r using VS.NET 2005 u can do it in a very simple way by using an SqlDataSource object. You can configure the SqlDataSource object by appropriately selecting the server name, the database and the table u want to add the data. Then it automatically generates the SELECT,INSERT,UPDATE,DELETE statements or u can use ur own stored Procedures to do them. then drag n drop a formview on to the application and set it's datasource to SqlDataSource. e.g: FormView1.DataSource = SqlDataSource1; FormView1.DataBind();

        C Offline
        C Offline
        cisco2103
        wrote on last edited by
        #3

        Not quite what I was looking for. I do have a datasource and what not but I am looking for a better way to grab the actualy entered data without having to declare 2 variables (Textbox and a integer) just to get the data from the formview.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups