Question What it is wrong in this code??

therealzeta

Member
Joined
Aug 9, 2008
Messages
19
Programming Experience
5-10
I copied this code form a very detailed tutorial, but, I am having a error just on this line:
VB.NET:
Protected Sub dsGrid(ByVal sender As Object, ByVal e As ObjectDataSourceMethodEventArgs) Handles dsGrid.Inserting



Error 1 'dsGrid' already declared as 'Protected Dim WithEvents dsGrid As System.Web.UI.WebControls.SqlDataSource' en class.C:\Inetpub\wwwroot\Consultorio\webProducto.aspx 14 17 C:\...\Consultorio\

Can anyone help me???

VB.NET:
protected Sub dsGrid(ByVal sender As Object, ByVal e As ObjectDataSourceMethodEventArgs) Handles dsGrid.Inserting
        ' Programmatically reference Web controls in the inserting interface...
        
' from this point on, i dont have any problem

        Dim DistribuidorId As DropDownList = GridView1.FooterRow.FindControl("ComboFootDistribuidor")
        Dim barcode As TextBox = GridView1.FooterRow.FindControl("txtfootbarcode")
        Dim nombre As TextBox = GridView1.FooterRow.FindControl("txtfootnombre")
        Dim sust_Activa As TextBox = GridView1.FooterRow.FindControl("txtfootSustancia")
        
        Dim Envase As DropDownList = GridView1.FooterRow.FindControl("comboFootEnvase")
        Dim cantEnv As TextBox = GridView1.FooterRow.FindControl("txtFootEnvCant")
        Dim costoEnv As TextBox = GridView1.FooterRow.FindControl("txtFootEnvcosto")
        Dim ventaEnv As TextBox = GridView1.FooterRow.FindControl("txtfootEnvVenta")
        
        Dim minimo As DropDownList = GridView1.FooterRow.FindControl("comboFootMinimo")
        Dim cantmin As TextBox = GridView1.FooterRow.FindControl("txtfootminCant")
        Dim costoMin As TextBox = GridView1.FooterRow.FindControl("txtFootmincosto")
        Dim ventaMin As TextBox = GridView1.FooterRow.FindControl("txtFootMinVenta")
       
        
        'Dim NewUnitsInStock As TextBox = _
        'GridView1.FooterRow.FindControl("NewUnitsInStock")
        
          
        
        
        ' Set the ObjectDataSource's InsertParameters values...
        e.InputParameters("DistribuidorId") = DistribuidorId.SelectedValue
        e.InputParameters("barcode") = barcode.Text
        e.InputParameters("nombre") = nombre.Text
        e.InputParameters("sus_activa") = sust_Activa.Text
        
        e.InputParameters("envase") = Envase.SelectedValue
        e.InputParameters("cantEnv") = cantEnv.Text
        e.InputParameters("costoEnv") = costoEnv.Text
        e.InputParameters("ventaEnv") = ventaEnv.Text
        
        e.InputParameters("minimo") = minimo.SelectedValue
        e.InputParameters("cantmin") = cantmin.Text
        e.InputParameters("costomin") = costoMin.Text
        e.InputParameters("ventamin") = ventaMin.Text
 
Last edited by a moderator:
Sounds as you have declared 'dsGrid' variable two places.

Take notice that you have to post English text at this site. I translated your error message from Spanish and fixed your post. Also try to use formatting when you post messages, it makes it all friendlier to read and understand. Formatting is very easy like any other text editor.
 
Supply a better Sub Name

Sounds like you have dsGrids mentioned more than once in your code. Simply right-click on dsGrids in code view and select Find all References. Make sure that wherever you see the references that it only mentions one type of variable or object.

You could also try supplying your own sub name. Instead of Protected Sub dsGrid(etc.....) try, Protected Sub dsGrid_Inserted(etc......). If the grids name is dsGrid then any methods using the same exact name can cause conflict.

Good Luck
 
It's a pleasure

Hi, well its only a pleasure to help out. We all have been through the learning phases and the only way to get to grips with programming is to be faced with a problem and then finding a solution by any means possible. I believe the best way to learn is to learn from mistakes, that's the only way I was able to understand programming considering that I just about failed it in highschool. Don't mention this to my boss though :p

Best of luck with the rest of your project!!
 

Latest posts

Back
Top