|
Hi
I try to develop an Web Application to manage films (a little bit like ImDB)
For the Edit part, I fill textboxes with a Linq query (on loading).
No problem to display the information in the different textboxes
But when I want to save changes into the database,
my textboxes are empty (according to the debugger) even if I put a value in it.
A part of my code to do this edition :
Loading :
<br />
DBMovies_ClassesDataContext db = new DBMovies_ClassesDataContext();<br />
<br />
int IdFilm = int.Parse(Session["idfilm"].ToString());<br />
<br />
var editedfilm =<br />
(from f in db.Films<br />
where f.id == IdFilm<br />
select new { Title = f.title, Title_o = f.title_original, Language = f.language, DateRelease = f.date_release, Genre = f.genre, Runtime = f.runtime, Plot = f.plot, Country = f.country }).Single();<br />
<br />
<br />
txtCountry.Text = editedfilm.Country.ToString();<br />
txtDateRelease.Text = editedfilm.DateRelease.ToString();<br />
txtGenre.Text = editedfilm.Genre.ToString();<br />
txtLanguage.Text = editedfilm.Language.ToString();<br />
txtPlot.Text = editedfilm.Plot.ToString();<br />
txtRuntime.Text = editedfilm.Runtime.ToString();<br />
txtTitle.Text = editedfilm.Title.ToString();<br />
txtTitle_o.Text = editedfilm.Title_o.ToString();<br />
<br />
Code to update values in DB :
<br />
<br />
DBMovies_ClassesDataContext db = new DBMovies_ClassesDataContext();<br />
<br />
<br />
int IdFilm = int.Parse(Session["idfilm"].ToString());<br />
<br />
var updateFilm = (from f in db.Films<br />
where f.id == IdFilm<br />
select f).Single();<br />
<br />
<br />
updateFilm.country = form1.FindControl(txtCountry.ID).ToString();<br />
<br />
updateFilm.country = txtCountry.Text.ToString();<br />
updateFilm.title = txtTitle.Text.ToString();<br />
updateFilm.title_original = txtTitle_o.Text.ToString();<br />
updateFilm.language = txtLanguage.Text.ToString();<br />
if (txtDateRelease.Text != "") { updateFilm.date_release = DateTime.Parse(txtDateRelease.Text); }<br />
updateFilm.genre = txtGenre.Text.ToString();<br />
if (txtRuntime.Text != "") { updateFilm.runtime = Int32.Parse(txtRuntime.Text); }<br />
updateFilm.plot = txtPlot.Text.ToString();<br />
<br />
db.SubmitChanges();<br />
<br />
and an exemple of my textboxes :
<asp:label id="lblCountry" runat="server" text="Country : "></asp:label><br />
<asp:textbox id="txtCountry" runat="server"></asp:textbox>
All the elements are working well
It's just the empty textboxes which ruin everything
Thank you by advance
(and sorry if there are english mistakes)
Cedric.
|
|
|
|
|
hi
i want to create custom pictureBox with panning and zooming functinallity, for start, i found this article :
http://www.codeproject.com/KB/GDI-plus/PanZoomExample.aspx[^]
but it's in Vb and when i convert it to c#, it take me some error(s) and i don't know what that error (because i don't know vb), can anyBody help me for this aim ? (article and sample code in c#)
thanks.
|
|
|
|
|
The article provides a dll which you can add to your program as a reference and use classes inside it. No need to convert it in C#.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi, I am using a VC++ dll in which "GetNamedSecurityInfo" and "GetExplicitEntriesFromAcl" API are being used for accessing Shared folder rights and number of users.
This Dll is returning correct number of users when I am using it in a Windows Application.
But, it is returning number of users as 0(for the same folder), If I am using it from a Web Application.
Plz help !!!
DDeepali
|
|
|
|
|
Hi All,
I am working on a project in which a person has to enter multiple data at the same time...
as there is a window have 3 text boxes like
Article Name
Article type
Price
... so a person can purchase mutiple article ...
i kept 3 buttons on this form as"ok"," submit ",cancel.
when you say ok it will save the data of respective field some here and wait for the next ok if again ok save both data some where and wait till untill submit or canncel...
if submit is pressed so the data have to be displayed as a report....
so where i can save this data .... i ll delete this file after every click of cancel or submit.
please help me here...
Thanks in advance..
T@SU
|
|
|
|
|
hi,
use datagridview for store multiple item. Let me explain
when user click on first time ok button then it add a row in datagridview and store the value of all three field in three column. and when user click on ok button second time, then it adds one more row for this entry and so on.
after that when user click on submit button, your program check each row of datagridview and save info.
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
No i need not to show the record ...
i just need to save the data some where so that during printing the report i need to show the data..
as prices are there so i have to sum up all the prices for each article ...
like wise i have save the data ..
Thanks alot for ur reply..
vikas da
|
|
|
|
|
sorry i forgate to tell u..
i dont want to use data base coz these are the temporary values...
as we are more in printing the value...
vikas da
|
|
|
|
|
hi vikas,
you can off the visiblity of datagridview.and calculate the price by add the value of price related column. if you don't like this option, then you can choose two-dimensional array .
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Hello everyone,
Any general rules/practices to avoid "ObjectDisposedException"-- System.ObjectDisposedException: Cannot access a disposed object?
thanks in advance,
George
|
|
|
|
|
If the object provides IsDisposed property, check that.
|
|
|
|
|
Thanks N a v a n e e t h,
I agree and understand it works. But is it an elegant way? Since for every operation I need to check IsDisposed to be true or false?
Do you have any other ideas?
regards,
George
|
|
|
|
|
George_George wrote: Since for every operation I need to check IsDisposed to be true or false?
You should dispose the object only when you finish using it. If you have still work with that object, keep it alive, don't dispose. Correct me if I haven't got your question.
|
|
|
|
|
Thanks N a v a n e e t h,
I am in a multi-threaded environment, some thread will dispose the object, when some other threads executing method on the object, it will have such exception.
Any advice to my situation to resolve this exception?
regards,
George
|
|
|
|
|
Means your code is not thread safe. Here is my suggestions
1 - Create new instance of the disposable object for each thread. So it can dispose when it finishes.
2 - If you are sharing the same disposable instance, use some kind of synchronization mechanism to ensure no threads are disposing it when another one uses.
|
|
|
|
|
Good suggestion, thanks N a v a n e e t h!
regards,
George
|
|
|
|
|
I have checked that the exception is from EndGetContext method of HttpListener class, when will it throw ObjectDisposedException?
regards,
George
|
|
|
|
|
George_George wrote: when will it throw ObjectDisposedException?
When it is disposed. Hard to tell more without seeing your code.
|
|
|
|
|
|
I don't think that it is a good method. When you call End() and catch exception, it's not sure that asynchronous method has finished doing it's job. When an exception rises, it stops processing and throw the application when End() is called. So I suggest you to look through the suggestions which I have in the previous post.
|
|
|
|
|
Thanks N a v a n e e t h,
I agree with your solution. I am more interested in why there is ObjectDisposedException when I call End method. Does it mean some other parties (maybe some backend IO threads by OS or CLR) disposed the HttpListener object instance before I call End method?
regards,
George
|
|
|
|
|
Since you are in a mutithreaded environment and not using any synchronization techniques, there are chances for another thread to dispose the shared instance. This is causing exception. Since you are using asynchronous method pattern, exception won't be thrown immediately, asynchronous methods stops the execution and keep the exception to another variable for future use. This will be thrown when you call End() method.
|
|
|
|
|
Thanks N a v a n e e t h,
I totally agree with your analysis. Is it possible to add some code to monitor which process calls the Dispose method of HttpListener? I have checked my code is not invoking Dispose method explicitly.
My suspecisions,
1. Some code I used will be expanded by C# compiler, which contains Dispose method invocation -- even if I do not call it explicitly.
2. Some CLR internal threads call Dispose method, since the situation happens when the network environment is roaming, and clinet frequently disconnects from server (I am writing an Http server).
Any advice to make further analysis?
regards,
George
|
|
|
|
|
George_George wrote: Is it possible to add some code to monitor which process calls the Dispose method of HttpListener?
Don't know exactly - But if HTTPListener class allows inheriting, you can override Dispose(bool) method and check it is being called.
George_George wrote: Some CLR internal threads call Dispose method, since the situation happens when the network environment is roaming, and clinet frequently disconnects from server (I am writing an Http server).
I don't have any prior experience on using this class. So I don't know what's going wrong here. But CLR calls the Dispose method only when garbage collection is happening. I guess even the client got disconnected, your HTTPListener instance will be still active until garbage collection unless you release it by calling Dispose() explicitly.
|
|
|
|
|
Thanks N a v a n e e t h,
I have checked HttpListerner class is sealed and we can not inherits it.
public sealed class HttpListener : IDisposable
I have some further ideas, I think when we complete asynchronous method call by using End method, all exceptions during the method call will be raised to the End method. Maybe it is some other component is Disposed. I have this idea is because I agree with you that the Listener object should live not regarding of the client connection termination.
Any ideas to find out which object is Disposed? I catch ObjectDisposedException in End method.
regards,
George
|
|
|
|