Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Databinding in c#

  • 02-03-2004 6:40pm
    #1
    Registered Users, Registered Users 2 Posts: 618 ✭✭✭


    I am trying to databind information from table to a label. The table is called Hole and i want to take the enteries from HoleId to a Label. The first time i try to databind it, it works the second time i select the next row it does'nt work it comes up with an error message. The design of the table is below.
    Hole
    HoleId
    1
    2
    3
    4

    This is the code where am i going wrong...!

    lblHole1.DataBindings.Add("Text", ds.Tables[0],"HoleId"); <<works>>

    blHole2.DataBindings.Add("Text",ds.Tables[0].Rows[1],"HoleId");<<does'nt work">>


    If you want more information place a reply


Comments

  • Registered Users, Registered Users 2 Posts: 640 ✭✭✭Kernel32


    Based on that code snippet I don't think you understand databinding very well. When you databind a control such as a label it is expecting to be bound to a single value, in this case the HoleID column in the first row of the datatable. What you seem to want to do is have a list of HoleID's? If so then use the datagrid or datalist and bind to that instead. If your using VS.Net then you don't even have to write any code, just use the designer and if you use a typed dataset instead on untyped dataset then the designer works even better.


  • Registered Users, Registered Users 2 Posts: 618 ✭✭✭johnnyc


    see i am databinding a single value from holeid into 18 labels. I am trying to databind every hole into a single label. Thanks kernel for the suggection.


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    Hey spongebob, I'm not bitching or anything.. But you should really do some reading before posting on this board.. I'm just giving you a little bit of advice to make all of our lives easier. Before you post you should read the charter.. Although you did a good thing by posting some of your code, well done with that. As for databinding, check out the gotdotnet website and also msdn.microsoft.com and read the MSDN howto. Since you're doing your college project in c#, why not purchase a c# book? Some of the oreilly c# books are good, but don't buy any of those "Learn how not to be a sponge in 24 hours" kind of books

    My 0.02cent(s).


Advertisement