I have an ongoing debate with a co-worker about the merit of using server controls or code-behind for data, and I thought I'd post here for other people's opinions. I use SqlDataSources bound to controls, whereas he puts labels on the page and does everything in the code. (Oh, and I use stored procedures and not text commands, which I feel suffices for a DAL in small apps, so let's skip that argument.) I like it because it seems cleaner, faster, more concise, and gives access to the control events so work can be done at the appropriate time. Which do you prefer and why?
Using controls such as SqlDataSource is faster in some respects, however, it does not suffice as a true DAL, not even with stored procs. (Its an argument you will loose 9 out of 10 time). This method binds the presentation to data much too strongly for me. You should be able to build the application so each layer is independent.
I would say you are both right to a certain extent. The co-worker who is building everything by hand is going too far. DataBinding and templates can be used quite effectively. Separating the presentation and data, such as in a MVC or MVVM pattern gives much more flexibility and code reuse.
Are this labels put on the form only once at the beggining of the page "lifecycle"? If yes - then declarative way would be better for traffic. Because each change of the page, which occurs in OnLoad() method is added to ViewState and travels to client with html page. If labels will be defined in .aspx then they will be created on Init() step and there will no additional ViewState data
does anybody use pdfbox? It is built into an application that I just inherited and suddenly has an Index was outside the bounds of the array. error. Now I do know what that means generally, however the debugger does not show me where its screwing up as it is withing pdfbox itself not part of the application code in and of itself. Its on a line call that has worked for over a year. No code has been updated, no servers have been updated(in regards to this app)
The application as a whole goes to a outside party website and pulls down a pdf file, that part works fine. It then used pdfbox to strip particular text out of that pdf file and puts that into a database. The text strip is where things have suddenly gone wonky.
My only thought so far is that the format of the pdf has been changed somehow but I cant tell where and again, its third party as well. So if anybody uses this particular tool and has had this issue in any way, a little hint of the right direction would be helpful.
Programming is a race between programmers trying to build bigger and better idiot proof programs, and the universe trying to build bigger and better idiots, so far... the universe is winning.
I have a gridview, grid1 on the page which loads using the SqlDataSource, all the code is on the same page, the connection string, insertcommand etc. Everything is good and results display.
now, I have given the users the option to search. I want to bind the search results to the same grid1, the results would look the same except filtered on search criteria. When I try to use the same sql connection it comes back with WebControls.SqlDataSource and sqlclient.sqlconnection conversion issue. Is there a way to bind my search results to this grid as well?
I am trying to get the file path which I choose to upload. I mean the value of the textbox of the file upload control. With this code:
I just only get the file name not the path. I tried
and that didnt work either. I get a path of my project. Any ideas how i can do this?
To be more clear what I am trying to do:
When the user uploads a file I rename the file and save it to a folder. After saving it to the folder I want to delete uploaded file from its original source. Such as the user upload the file from its desktop. I save the file to a folder udner C://Folder name. I want to delete the file from the desktop.
As you are talking about uploading files, I am guessing that this is an asp.net project. If it is you cannot access the users desktop from the brower. It is a security risk. The browser will allow you to read files to upload only. The only way you could achieve this is using flash or a browser plugin that is not constrained but the browsers security sandbox.