Hi all,

Have been working with datagridviews with datasets, bindingsources, comboboxes, etc.

I was having a problem that prompted me to ask a question. First, the problem that I was having. I created a datagridview that was bound to a dataset and then added code that created columns and some comboboxes on those columns. However, I had a problem with the code executing properly until I got rid of the coded comboboxes and used the datagridview IDE to add columns and change them to comboboxes.

The question I have isn't what I was doing wrong, but rather, which is the better method to go about using datagridviews/datasets/bindingsources. I'm new to this, but it seems that things can get pretty nasty quickly when mixing code/IDE with respect to this if one isn't careful.

With that said, just looking for some lessons learned and good practice type of feedback.

Thanks!

Recommended Answers

All 2 Replies

Personal point of view when it comes to ASP.Net componentry is this:

  • If you are going to code part of it on the front-end, code all of it on the front-end
  • If you are going to code part of it on the back-end, code all of it on the back-end

Coding and databinding is handled in completely different ways when coded in front vs back end processes and they can often conflict or cause rather unique issues. Part of the problem comes from the fact that, while all code on the back-end is handled 'sequentially' (unless you get into multi-threading, which I don't) the code on the front-end is not necessarily going to execute 'in synch' with what's going on in the back end. This can result in calls to information on the back end that are related to information not yet generated on the front end (or vice-versa). As a result, it's usually best to keep all related code in the same place as opposed to mixing the two.

Now, to clarify, I'm not saying "code your entire application" on the front or back end, but if a specific component is being generated in one or the other then the related code for manipulation of that component should all be in the same place. The only exception in this case would be code that handles events driven AFTER the page has been fully loaded (event handles, button clicks, etc) as by the point where they would be utilized all data population should have occurred (presumeably).

Hope that made sense and was of some help to you :)

There are many things that cannot be accomplished through the IDE as you know, but you still have to use it on top of code with VS. Not like our nice friend C.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.