Here is my content page structure:
Listview with 3 columns - label(s.no), Imagebutton(view Record), label(item name).
The Imagebutton has oncommand="view".When clicked, it displays, that row's details in the respective textboxes that are below.
Textbox(itemname)
Textbox(itemcode)
Problem:
When the cursor is in any of the textbox, and I press 'Enter', it is firing the 'View' command event, meaning... I get the details of the first row in the listview, displayed in these textboxes.
I do not want this to happen. Is this behaviour due to the 'DefaultButton' property set somewhere? I tried finding the same in the entire solution but could not.
There are master and content pages and this issue is in every content page.
How can I find out, which control has this property, or what causes this behaviour.
This is the default behaviour of a HTML page.
In ASP.NET, the Panel control has a DefaultButton property that you can set and will change this behaviour. You can put textboxes in a Panel and set the DefaultButton property of the panel.
Related
Both the 'Load' button on tabPage2 and the 'Load' Menu Item are running the same code, but as you can see in the demo above when the control is added when tabPage2 is not selected, the column widths shuffle despite it being the exact same code, the exact same control with the exact same content.
I'm not sure how relevant it is to the problem, but the UserControl I am adding looks like this:
Just a tab control with two tabs, a split container on the first tab with a DataGridView in the bottom split panel.
Each 'Load' creates a new tab page, a new user control, adds the user control to the tab page and then adds the tab page to the tab control on tabPage2.
Is there something at play here that I'm not aware of that would make controls render differently depending on their visibility when added?
EDIT: The DataGridView's are using DataGridViewAutoSizeColumnsMode.Fill
It does not have anything to do with the visibility of the tabs when adding the user control. To confirm you can keep the tabPage2 selected and you will see the same behavior as you currently have.
It is the selection and highlights of the tab controls that must be giving that notion. You can try adding around 4 user controls and click between tab2 and tab3 to confirm.
I have a user control and the user control is having a grid and some buttons inside that.
Inside the grid I added user control as item template. So while binding the grid,it contains multiple number of usercontrols as row inside the grid. All those are inside a radajaxpanel.
Now in my user control there is a button called btnSave. I am triggering the postback from by using a javascript.
by __doPostBack('btnSave','someValue'); So its triggers postback and working fine.While clicking save I am updating the grid.Its working fine. But if the grid contains 10 items (ie 10 user controls) it will trigger 10 postbacks and updates the other grids also. How to avoid the extra post back and avoid binding other grids.
What I tried.
using clientID and uniqueiD. Post back works but the binding is not working. The grid is not updating. When I changed it to
'btnSave' all are working, but other grids inside the usercontrol also get binded.
I hope my issue is clear and thanks for any suggestions.
This old chestnut again.
My page is constructed as follows; I have a dropdownlist which is databound on first load. When the user selects a value from this, a postback is performed which then databinds a repeater control.
The ItemTemplate of this repeater control contains a placeholder control. In code behind in the ItemDataBound event of the repeater, I am adding two controls dynamically to this placeholder, a hiddenfield and a checkbox.
When the user clicks the save button, I then want to iterate over all those dynamically created hiddenfields and checkboxes and determine their values. However when the user clicks the save button, those controls no longer exist as shown in the page trace.
I know this is a lifecycle issue and the articles I've seen on this suggest using Init methods to dynamically create your controls but I can't because of the way my page works, e.g. the repeater control only appears and binds after a value is chosen from the dropdownlist.
What do I need to do to maintain the dynamic controls through the postback caused by clicking on the save button?
The problem is when you hit the save button probabily you dont re-bind the repeater and the controls you have added at run time withint the ItemDataBound event are not longer available(because they don't exist anymore)
Why don't you add those control at design time using the Eval function the set up the value of the hidden field?
You just don't create them dynamically just on the on selection change of the drop-down set visibility true or false for the repeater that will solve your problem.on post back you have to again create those control as they are Dynamically created.
I have a a gridview with a dynamic number of columns and rows. In each of the gridiview cells, a textbox get's added dynamicaly. I need users to be able to tab through these textboxes, but I can't get it to work.
I set the tabindex of the the textbox when it is created in the code behind, however when I try and tab in the page it doesn't work. If I click inside a textbox in the grdiview then pressing tab does nothing at all, If I click outside the gridview I can tab through the other controls on the page, and it will tab into the first cell of the gridiview, and then stop/
Perhaps you can create a javascript method to get a list of all textboxes on the page, and shift focus to the next one, by checking for a keypress event?
Well I solved the problem. I had some javascript running on Key Down to prevent users entering anything other than numbers, which blocked tabbing. Removed it and it worked.
I have a child GridView which is displayed when a user selects a row in a the parent GridView. What the user can do is select items in the Gridview, which then go off to a results page. However, what I have is a button on the page which when clicked shows the user what they have selected. The problem is that when the button is pressed the child gridview is hidden, how do I (if it has been selected/displayed) keep it open/displayed?
Do I have to set up a variable which will hold whether the child gridview has been displayed, can I put it in the pages viewstate (I don't know anything about this as all this .net stuff is new to me)?
Thanks R.
Something quick you could try is to set
Visble=True
For your parent and child gridview in the button's handler
It's difficult to say without some sample code, but another possiblility is that when the button is clicked, the parent gridview is rebound to a data source (probably in the Page_Load event), but not the child gridview. Try rebinding the child gridview to its data source right after the parent gridview.
gvChildGrid.DataSource = {some data source};
gvChildGrid.DataBind();