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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Datagrid Question

Datagrid Question

Scheduled Pinned Locked Moved Visual Basic
questionwpfwcfhelptutorial
15 Posts 3 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.
  • M Offline
    M Offline
    maxiachun
    wrote on last edited by
    #1

    i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ?? emergency!! so everyone pls help me!! I am Entry level person

    S 1 Reply Last reply
    0
    • M maxiachun

      i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ?? emergency!! so everyone pls help me!! I am Entry level person

      S Offline
      S Offline
      Steve Pullan
      wrote on last edited by
      #2

      maxiachun wrote:

      i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??

      Seems fairly straight forward to me. What is the problem you are experiencing? Elaborate more and you may get a sensible answer.

      maxiachun wrote:

      emergency!! so everyone pls help me!!

      What sort of emergency? If this is for a uni project/homework etc, sorry but you've come to the wrong place. ...Steve

      M C 3 Replies Last reply
      0
      • S Steve Pullan

        maxiachun wrote:

        i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??

        Seems fairly straight forward to me. What is the problem you are experiencing? Elaborate more and you may get a sensible answer.

        maxiachun wrote:

        emergency!! so everyone pls help me!!

        What sort of emergency? If this is for a uni project/homework etc, sorry but you've come to the wrong place. ...Steve

        M Offline
        M Offline
        maxiachun
        wrote on last edited by
        #3

        hehe! i need a bit help becoz i have problem in Currency manager binding! so i want someone to give me some advice! I am Entry level person

        1 Reply Last reply
        0
        • S Steve Pullan

          maxiachun wrote:

          i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??

          Seems fairly straight forward to me. What is the problem you are experiencing? Elaborate more and you may get a sensible answer.

          maxiachun wrote:

          emergency!! so everyone pls help me!!

          What sort of emergency? If this is for a uni project/homework etc, sorry but you've come to the wrong place. ...Steve

          M Offline
          M Offline
          maxiachun
          wrote on last edited by
          #4

          here is some code! Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try If cnn.State = ConnectionState.Closed Then cnn.Open() da.Fill(ds.ProductTable) dv = New DataView(ds.ProductTable) cm = CType(Me.BindingContext(Me.ds, "ProductTable"), CurrencyManager) If System.IO.File.Exists(sFile) Then Me.Prizes1.ReadXml(sFile) End If End If Catch ex As Exception MsgBox(ex.Message) Finally cnn.Close() End Try End Sub Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click Dim strFilter As String = "PLU_Number > 0" If txtCode.Text.Length > 0 Then strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'" End If If txtPLU.Text.Length > 0 Then strFilter = strFilter & "and PLU_Number like '" & txtPLU.Text & "%'" End If If txtDescription.Text.Length > 0 Then strFilter = strFilter & "and Description like '" & txtDescription.Text & "%'" End If dv.RowFilter = strFilter DataGrid1.DataSource = dv End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim dr As Prizes.PrizeTableRow Try With CType(cm.Current.row, ds.ProductTableRow) dr = Me.Prizes1.PrizeTable.NewRow() dr.Inventory_Code = .Inventory_Code dr.Qty = 1 dr.Awarded = 0 Me.Prizes1.PrizeTable.Rows.Add(dr) End With Catch ex As Exception End Try End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Me.Prizes1.WriteXml(sFile) End Sub End Class I am Entry level person

          S C 2 Replies Last reply
          0
          • S Steve Pullan

            maxiachun wrote:

            i want to select one row from one datagrid which is binding to a dataset, then click add button to add this row into the datagrid below, how to implement this ??

            Seems fairly straight forward to me. What is the problem you are experiencing? Elaborate more and you may get a sensible answer.

            maxiachun wrote:

            emergency!! so everyone pls help me!!

            What sort of emergency? If this is for a uni project/homework etc, sorry but you've come to the wrong place. ...Steve

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Steve Pullan wrote:

            What sort of emergency?

            There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault. But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself. Christian Graus - Microsoft MVP - C++

            S 1 Reply Last reply
            0
            • M maxiachun

              here is some code! Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try If cnn.State = ConnectionState.Closed Then cnn.Open() da.Fill(ds.ProductTable) dv = New DataView(ds.ProductTable) cm = CType(Me.BindingContext(Me.ds, "ProductTable"), CurrencyManager) If System.IO.File.Exists(sFile) Then Me.Prizes1.ReadXml(sFile) End If End If Catch ex As Exception MsgBox(ex.Message) Finally cnn.Close() End Try End Sub Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click Dim strFilter As String = "PLU_Number > 0" If txtCode.Text.Length > 0 Then strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'" End If If txtPLU.Text.Length > 0 Then strFilter = strFilter & "and PLU_Number like '" & txtPLU.Text & "%'" End If If txtDescription.Text.Length > 0 Then strFilter = strFilter & "and Description like '" & txtDescription.Text & "%'" End If dv.RowFilter = strFilter DataGrid1.DataSource = dv End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim dr As Prizes.PrizeTableRow Try With CType(cm.Current.row, ds.ProductTableRow) dr = Me.Prizes1.PrizeTable.NewRow() dr.Inventory_Code = .Inventory_Code dr.Qty = 1 dr.Awarded = 0 Me.Prizes1.PrizeTable.Rows.Add(dr) End With Catch ex As Exception End Try End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Me.Prizes1.WriteXml(sFile) End Sub End Class I am Entry level person

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              maxiachun wrote:

              Dim strFilter As String = "PLU_Number > 0" If txtCode.Text.Length > 0 Then strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'"

              Here's an issue. You need a space after the 0, otherwise it looks like this: PLU_Number > 0and Inventory_Code like etc. Looking at the values in the debugger is a good way to find errors like this one, and always trailing a space if you must build SQL like this is another. Of course, you shouldn't build your SQL like this, for starters, if this is a real world app, you're wide open to injection attacks. Christian Graus - Microsoft MVP - C++

              M 1 Reply Last reply
              0
              • M maxiachun

                here is some code! Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try If cnn.State = ConnectionState.Closed Then cnn.Open() da.Fill(ds.ProductTable) dv = New DataView(ds.ProductTable) cm = CType(Me.BindingContext(Me.ds, "ProductTable"), CurrencyManager) If System.IO.File.Exists(sFile) Then Me.Prizes1.ReadXml(sFile) End If End If Catch ex As Exception MsgBox(ex.Message) Finally cnn.Close() End Try End Sub Private Sub BtnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSearch.Click Dim strFilter As String = "PLU_Number > 0" If txtCode.Text.Length > 0 Then strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'" End If If txtPLU.Text.Length > 0 Then strFilter = strFilter & "and PLU_Number like '" & txtPLU.Text & "%'" End If If txtDescription.Text.Length > 0 Then strFilter = strFilter & "and Description like '" & txtDescription.Text & "%'" End If dv.RowFilter = strFilter DataGrid1.DataSource = dv End Sub Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim dr As Prizes.PrizeTableRow Try With CType(cm.Current.row, ds.ProductTableRow) dr = Me.Prizes1.PrizeTable.NewRow() dr.Inventory_Code = .Inventory_Code dr.Qty = 1 dr.Awarded = 0 Me.Prizes1.PrizeTable.Rows.Add(dr) End With Catch ex As Exception End Try End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Me.Prizes1.WriteXml(sFile) End Sub End Class I am Entry level person

                S Offline
                S Offline
                Steve Pullan
                wrote on last edited by
                #7

                maxiachun wrote:

                here is some code!

                Ok I see the code but what is the problem? On what line are you getting an exception or is it just not working as you expected? I'm not going to analyze it for you. Make it easy for me and I'll help. ...Steve

                1 Reply Last reply
                0
                • C Christian Graus

                  Steve Pullan wrote:

                  What sort of emergency?

                  There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault. But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself. Christian Graus - Microsoft MVP - C++

                  S Offline
                  S Offline
                  Steve Pullan
                  wrote on last edited by
                  #8

                  Christian Graus wrote:

                  There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault. But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself.

                  Yep, I agree on all counts. My last reply (probably as you were writing this one to me) was a bit abrupt, but all I got was some source code. I'm not going to analyze anyone's code unless there is evidence that he/she has done some work and provided a decent description of the problem. Call me old fashioned :-) It saddens me that untrained people are actually cutting code. Part of the problem of such high level tools that make it easier I guess - and employers' expectations. I'm glad you have more patience than me :-). Anyway - back to lurking... Cheers ...Steve

                  C M 2 Replies Last reply
                  0
                  • S Steve Pullan

                    Christian Graus wrote:

                    There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault. But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself.

                    Yep, I agree on all counts. My last reply (probably as you were writing this one to me) was a bit abrupt, but all I got was some source code. I'm not going to analyze anyone's code unless there is evidence that he/she has done some work and provided a decent description of the problem. Call me old fashioned :-) It saddens me that untrained people are actually cutting code. Part of the problem of such high level tools that make it easier I guess - and employers' expectations. I'm glad you have more patience than me :-). Anyway - back to lurking... Cheers ...Steve

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    Steve Pullan wrote:

                    Call me old fashioned

                    No, I agree totally.

                    Steve Pullan wrote:

                    t saddens me that untrained people are actually cutting code.

                    Yeah, I think it's a sign that employers are valuing what we do as being worth less and less. Not wanting to ignite the language wars, but it's definately more the case with VB than C++. In fact, I did a job in C# ( a video jukebox ) and the client would not consider C++ and was really keen on VB ( I refused the job in VB, due to personal preference ), because VB coders are 'cheap and easy to find', and that because 'VB is easy'. It's only a matter of time before this end of the market makes no more money than a bank teller or checkout chick, because the tools ARE easier, and sites like this one make it easier again.

                    Steve Pullan wrote:

                    Part of the problem of such high level tools that make it easier I guess - and employers' expectations.

                    Yeah, it's both of those things. And for the record, I don't expect C# to be much different in a few years time. I still love C# though, especially with the C# 2.0 ( and 3.0 ) stuff that I've seen. There will always be people willing to hack code for $10 an hour, but the people who employ those folks will get the systems they deserve, and pay the price when we're called in to fix them. I know, I've done it on some VB/ASP.NET sites already. Christian Graus - Microsoft MVP - C++

                    M 1 Reply Last reply
                    0
                    • C Christian Graus

                      maxiachun wrote:

                      Dim strFilter As String = "PLU_Number > 0" If txtCode.Text.Length > 0 Then strFilter = strFilter & "and Inventory_Code like '" & txtCode.Text & "%'"

                      Here's an issue. You need a space after the 0, otherwise it looks like this: PLU_Number > 0and Inventory_Code like etc. Looking at the values in the debugger is a good way to find errors like this one, and always trailing a space if you must build SQL like this is another. Of course, you shouldn't build your SQL like this, for starters, if this is a real world app, you're wide open to injection attacks. Christian Graus - Microsoft MVP - C++

                      M Offline
                      M Offline
                      maxiachun
                      wrote on last edited by
                      #10

                      so what is the solution for building SQL how to do?? I am Entry level person

                      C 1 Reply Last reply
                      0
                      • M maxiachun

                        so what is the solution for building SQL how to do?? I am Entry level person

                        C Offline
                        C Offline
                        Christian Graus
                        wrote on last edited by
                        #11

                        Well, at a bare minimum you should check the text for quotes, so that the string coming in doesn't close the quotes ( which is how an injection attack occurs ). There's at least one article here on CP about this, search for 'SQL injection' to find it. Even if you use stored procs instead of building SQL, you're vunerable if you don't clean your input first. Christian Graus - Microsoft MVP - C++

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          Steve Pullan wrote:

                          Call me old fashioned

                          No, I agree totally.

                          Steve Pullan wrote:

                          t saddens me that untrained people are actually cutting code.

                          Yeah, I think it's a sign that employers are valuing what we do as being worth less and less. Not wanting to ignite the language wars, but it's definately more the case with VB than C++. In fact, I did a job in C# ( a video jukebox ) and the client would not consider C++ and was really keen on VB ( I refused the job in VB, due to personal preference ), because VB coders are 'cheap and easy to find', and that because 'VB is easy'. It's only a matter of time before this end of the market makes no more money than a bank teller or checkout chick, because the tools ARE easier, and sites like this one make it easier again.

                          Steve Pullan wrote:

                          Part of the problem of such high level tools that make it easier I guess - and employers' expectations.

                          Yeah, it's both of those things. And for the record, I don't expect C# to be much different in a few years time. I still love C# though, especially with the C# 2.0 ( and 3.0 ) stuff that I've seen. There will always be people willing to hack code for $10 an hour, but the people who employ those folks will get the systems they deserve, and pay the price when we're called in to fix them. I know, I've done it on some VB/ASP.NET sites already. Christian Graus - Microsoft MVP - C++

                          M Offline
                          M Offline
                          maxiachun
                          wrote on last edited by
                          #12

                          Anyway thank you for you two's help! i have just learned this for one and half months, i do need some help in certain field! if i really know how to manage all the objects and functions in VS.net , i also can solve the problem by myself. i am here becoz i need some experienced people to teach me new things andgive me some idea. if someone want to help i really appreciate it. VB.net is really like a designer, there is not many thinking things in it, once you have done something then you are able to do it! expirience is the key here. i put my problem here coz i have never seen this kind of problem then i need help and i want to develop my future on this. i won't use anyone else's code to make money for myself. I am Entry level person

                          1 Reply Last reply
                          0
                          • S Steve Pullan

                            Christian Graus wrote:

                            There seems to be a growing trend of people with no skillset being asked to write code by their employers, and coming here for help. It's not their fault, really, it's the employers fault. But you're right, it's equally possible he wants us to do his homework. I'd be happy to help him though, if he can demonstrate that he's tried to tackle the problem himself.

                            Yep, I agree on all counts. My last reply (probably as you were writing this one to me) was a bit abrupt, but all I got was some source code. I'm not going to analyze anyone's code unless there is evidence that he/she has done some work and provided a decent description of the problem. Call me old fashioned :-) It saddens me that untrained people are actually cutting code. Part of the problem of such high level tools that make it easier I guess - and employers' expectations. I'm glad you have more patience than me :-). Anyway - back to lurking... Cheers ...Steve

                            M Offline
                            M Offline
                            maxiachun
                            wrote on last edited by
                            #13

                            thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here! I am Entry level person

                            S 1 Reply Last reply
                            0
                            • M maxiachun

                              thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here! I am Entry level person

                              S Offline
                              S Offline
                              Steve Pullan
                              wrote on last edited by
                              #14

                              maxiachun wrote:

                              thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here!

                              Please re-read my original replies to your question and you'll see that I WAS trying to help. It took me at least two replies to get anything meaningful from you about this problem of yours. Like I said in the beginning - the more information you can give about the problem in the first place makes it easier for us as more experienced developers to provide you with the correct level of help. Simply giving us source code to analyze and debug is not good enough - you must provide sufficient information for us to help you. This may sound a bit harsh but we get varying degrees of help requests here - from homework to real-world problems - and in the recent past the homework guys have been peppering the board with useless and unresearched questions. To be quite frank, I thought your question was in the same boat, but I tried to help anyway! I wish you all the best sorting out this problem. ...Steve

                              M 1 Reply Last reply
                              0
                              • S Steve Pullan

                                maxiachun wrote:

                                thank you anyway! i donot need someone to teach me a lesson! i just want to learn something through here! and i know you are very good but it does not mean you can judge person here! maybe i misunderstand you, but i just donot feel good since i am trying to learn here!

                                Please re-read my original replies to your question and you'll see that I WAS trying to help. It took me at least two replies to get anything meaningful from you about this problem of yours. Like I said in the beginning - the more information you can give about the problem in the first place makes it easier for us as more experienced developers to provide you with the correct level of help. Simply giving us source code to analyze and debug is not good enough - you must provide sufficient information for us to help you. This may sound a bit harsh but we get varying degrees of help requests here - from homework to real-world problems - and in the recent past the homework guys have been peppering the board with useless and unresearched questions. To be quite frank, I thought your question was in the same boat, but I tried to help anyway! I wish you all the best sorting out this problem. ...Steve

                                M Offline
                                M Offline
                                maxiachun
                                wrote on last edited by
                                #15

                                anyway i have done it! thank you i was trying to let you understand me! I am Entry level person

                                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