I am working on a project where Telerik Controls are used. Earlier, grid was having 2 template columns with command button column for firing edit and delete command. Clicking on edit will automatically convert the edit button to an update button, and delete becomes cancel. Everything was working fine, until now.
Later I added two more textboxes inside that grid as templated column. And made relevant changes in code where the child controls are unboxed. But, on running, I found that the events are not firing. That is, Insert and Update; cancel, edit and delete are working fine.
One more thing, on clicking page does a postback, but the event is not fired.
Any ideas based on this scenario? Might be anybody already faced such conditions.
Note: I am working on remote Terminal, so clipboard operations and Internet are blocked there. We can only connect, write, compile, and execute code there. So I can't paste here the code for help.
I got it fixed, it was weird by anyhow I got it working. Issue was in radgrid template column i added an attribute visible ="false" and that made me sick. I removed that and every thing went fine..
I was facing this problem. I was explicitly binding the grid. I took that out and used NeedDataSource function. That solved my problem.
So if any one faces this issue, verify whether you are binding the grid anywhere else in the code behind file.
Related
Well, I found the problem I was facing with the post back earlier. Somehow it turns out that drop down list, is failing event validation in all the pages. It wasn't failing validation earlier, so no idea what happened.
Anyway, now I have some 400 pages where this thing is happening. So, adding some code in all of them is out of question. So, now I want to know what I can do to get the drop down list considered as valid during the postback? Adding update panel is out of question as I will have to do it on oh so many pages.
Edit:
More details:
I have an application created in .Net 1.1. I ran the upgrade wizard in VS to upgrade to VS2012. Since then, I am finding a lot of bugs when post back happens. I had two functions for handling click event for buttons. The javascript function (used for validation) is fired properly, but the asp function wasn't called at all.
So, last week, I set eventvalidation to false, and everything worked. After reading more about it, I realised that postback was failing validation check. I checked eventtarget attribute, but that was null. So, I kept looking further. After a lot of head scratching, I finally found the culprit of that postback failure.
In that application, we add items to the dropdown, based on database query results. So, it is modified on run time. The script modifying the control is added to "ClientScriptManager", but that doesn't work. So, right now, my code has some 400 forms with dozens of dropdownlist created in runtime.
I have to get these dropdownlist removed from postback validation, or somehow return true for the validation. And that's where lies the problem. I have no idea how to do this.
P.S. Do let me know, which piece of code I should add here, if needed.
I have a large-scale asp.net project that I'm working on (new to ASP.NET), and I have a problem with some dynamically added buttons not firing their click events on the first click. What's weird is that this doesn't always happen; sometimes they work just fine on the first click, and other times if I run the project and follow exactly the same steps the button won't work on the first click.
Here's some background...
The page that's problematic is used to deploy different versions of some content to clients. The page has an UpdatePanel that contains a bunch of tables, and only one of them is visible at any given time. Each table represents a different "screen" of a wizard-like workflow. So when the page is loaded, the first table is visible and all others are not, and the first page has a radio button list with deployment types and a Continue button. When the Continue button is clicked, some data is loaded for the next "screen" and the first table is made invisible and the next table is made visible.
So now that you have some background, on to the problem...
One of these tables has an empty Accordion on it, and when the previous "screen"'s Continue button is clicked, the Accordion is populated dynamically with data from the DB; there's one pane for each major version and each pane has a table in it with one row for each minor version. Each of these rows has the Version Number, the Deployment Status, and an Action button that lets the user Deploy the version, or if its already deployed they can Redeploy. Anyways, these action buttons are the ones that I have a problem with where they sometimes don't work on the first click. Like I said, the buttons are created in the click event from the Continue button on the previous "screen", and I set the ID of each button, and link the event up to the click event at the time the button is created. I can debug over this and see the event handlers being added with no problem, but then when I click the button the first time (and this is actually not consistent; sometimes they work on the first time!) they don't do anything, but on the second click they work normally. I have a method called something like populateAccordion() that is responsible for actually loading the data from the DB and creating these records with buttons in them. I call this method on page_load if it's a postback, but only if the cached selections from previous "screens" are not null (i.e. I cache a subjectId and centerId on previous "screens" and only load the Accordion data if those are not null).
This is a little too complicated to post code for, but does anyone have any ideas what could be going wrong, or how I could figure this out? I've done quite a bit of debugging, and my populateAccordion() is always called properly on the previous screen's Continue button click, and on every page_load after that, and the Click events are always wired up right when the buttons are created in that method, so I can't figure out why the click events wouldn't fire on the first try.
The problem is similar to the one mentioned in this post...
https://stackoverflow.com/a/2784140/1246574
But I am definitely setting the IDs for all of my buttons, so the solution mentioned in that post isn't the fix for my problem.
I've also read quite a few other posts that say to move your code from Page_Load to Page_PreRender, but that doesn't change anything in this case; it acts exactly the same.
I also tried setting the buttons' UseSubmitBehavior = false, but no luck.
Thanks!
This is probably a latency issue. It sounds like you're able to click the controls before the page has fully loaded all the JS. Is there an onload() function in there? Perhaps you could try hiding the controls until the page has finished loading?
This DGV is in a form that has been in production for months. I edited the form to add a checkbox to an unrelated function on the page. Built the solution and the DGV suddenly had all of its columns visible and all of the column prameters reset back to default.
I thought 'Well, thats wierd'. Changed the DGV back to what it was, hit the debug and ran the form. Everything looked good. Stopped the debug and lo and behold, all the columns were reset again.
I thought 'Well, thats irritating'. So I deleted the DGV, added a new one, set it up again and the new one did the same thing. Then I started playing with the columns and the DGV will only reset if certain columns are the only ones showing. I have stopped the bad behavior by leaving the columns that I want in and a few columns that I didnt want but are set to invisible.
I have not changed the datasset, I have not made any changes to the underlying data tables or stored procedures. But just to make sure I built another form with a DGV bound to the same Data set, no problems.
Not sure what to do at this point. Thing is working now but it was very annoying to have to spend a half hour trying to figure out why VS kept redesigning my form.
Has anyone else had this issue? I would include code but I dont think its a code issue. Visual Studio Voodo maybe.
I Had something similar, but different with DGV,
it was too long ago to remmember, but i remmember i put code to add columns in the constructor, which made the Designer to always add more and more.
.
Another possibility is that you have a different constructor made for the form, and Winforms designer does not call InitiateComponent() from it.
sorry i couldn't be of more help.
I have googled everywhere and I am finally giving up and asking here.
I am working in Visual Studio 2010 with C#. I have set up a form with a datagridview connected to a MSSQL database and I need to save changes made in the datagridview back to the physical database. I am having some success but I think that I am going about some of it completely wrong because I can not get it to save consistently.
What I really want is for the updates to work just like they do when working with Access. When I edit a row in the datagridview and then leave that row, either by selecting another row or by selecting some other control on the form or even by changing to another form or quitting the application the row should be automatically pdated to the physical database.
The first part of this question I think is, what is the proper event to use to trigger the save and then second what methods should be used to actually write the data to the database?
there are a lot of events that could be used including
Leave Event which Occurs when the input focus leaves the DataGridView
CellLeave Event which Occurs when a cell loses input focus and is no longer the current cell
RowLeave Event which Occurs when a row loses input focus and is no longer the current row
MSDN has info on each of the DataGridView Events
In the Event you use, you would place your code to perform the UPDATE. There are lots of answers on SO about updating the database:
WinForms DataGridView - update database
C# WinForms - how to send updates from DataGridView to DataBase
My suggestion would be try try some of this code and then if you have problems, post another question with your code.
I downloaded the source code from this tutorial after a failed attempt to make my own Wizard. The control works great and is integrating nicely into my program. I have one minor problem, though. I have a page that has both a databound ListBox and a databound TreeView. When changing to the next or previous page, the TreeView maintains its selections but the ListBox does not. Instead, it appears to update itself (judging by the flash). How can I prevent this from happening and maintain the user's selections?
Thanks,
Joe
Ugh! Serves me right for re-using code that I haven't looked at in a couple of months. Turns out the TreeView is not data bound but populated from a Value Object. I modified the ListBox to use its own VO and now it works perfectly. Kind of a complicated way of doing things but whatever works, right?