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. General Programming
  3. Visual Studio
  4. can anyone help me

can anyone help me

Scheduled Pinned Locked Moved Visual Studio
designcsharpvisual-studiohelp
4 Posts 2 Posters 2 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.
  • U Offline
    U Offline
    User 12064978
    wrote on last edited by
    #1

    I am trying to get a gridview to work using a selectedIndexChanged event handler. I want to "select" an item from the category then using a GridView, i want to display the products and offer the user a way to select a product. Upon selection, i want to handle the event by using the SelectedIndexChange event and display the primary key/productId for the product selected. My code does not seem to be working. I'm getting a null reference exception. I'm new to visual studio, it seems easy until i try and get something to work. here is my code so far

    Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub SqlDataSource1\_Selecting(sender As Object, e As SqlDataSourceSelectingEventArgs) Handles SqlCategories.Selecting
    
    End Sub
    
    Protected Sub GridView1\_SelectedIndexChanging(sender As Object, e As GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
        Dim intProductID As Integer = Nothing
    
        intProductID = GridView1.SelectedDataKey.Value
    
        Label1.Text = intProductID.ToString
    End Sub
    

    End Class

    I have a screen shot of my design view but do not see a way to post it here.

    L 1 Reply Last reply
    0
    • U User 12064978

      I am trying to get a gridview to work using a selectedIndexChanged event handler. I want to "select" an item from the category then using a GridView, i want to display the products and offer the user a way to select a product. Upon selection, i want to handle the event by using the SelectedIndexChange event and display the primary key/productId for the product selected. My code does not seem to be working. I'm getting a null reference exception. I'm new to visual studio, it seems easy until i try and get something to work. here is my code so far

      Partial Class _Default
      Inherits System.Web.UI.Page

      Protected Sub SqlDataSource1\_Selecting(sender As Object, e As SqlDataSourceSelectingEventArgs) Handles SqlCategories.Selecting
      
      End Sub
      
      Protected Sub GridView1\_SelectedIndexChanging(sender As Object, e As GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
          Dim intProductID As Integer = Nothing
      
          intProductID = GridView1.SelectedDataKey.Value
      
          Label1.Text = intProductID.ToString
      End Sub
      

      End Class

      I have a screen shot of my design view but do not see a way to post it here.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please use the correct forum: http://www.codeproject.com/Forums/1646/Visual-Basic.aspx[^]; this is not a Visual Studio issue.

      U 1 Reply Last reply
      0
      • L Lost User

        Please use the correct forum: http://www.codeproject.com/Forums/1646/Visual-Basic.aspx[^]; this is not a Visual Studio issue.

        U Offline
        U Offline
        User 12064978
        wrote on last edited by
        #3

        I am doing the project in Visual Studios =/ Where did you move my question to? I can't find it.

        L 1 Reply Last reply
        0
        • U User 12064978

          I am doing the project in Visual Studios =/ Where did you move my question to? I can't find it.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          What do you mean you can't find it? It is right where you posted it.

          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