Radiobutton checked change event not firing in gridview - c#

I have a gridview where i have a radio button. What i need is to on the selection of the radiobutton i have to find the datakey of the gridview. Also one more issue with that is , i can select more than one radio button, which should not happen.

You need to use a literal control to inject radio button markup.
This will handle grouping so only one radio button is selected.
You cannot do it with the standard radio control group.
See this for a complete example with working code:
http://www.asp.net/data-access/tutorials/adding-a-gridview-column-of-radio-buttons-vb

Related

group standard buttons together in C#

I was wondering if there is a way to group standard windows form buttons together, such as the way radio buttons can be, where only one can be selected at a time. I have four option buttons on my form, but only want one button to be able to be selected, and the background colour to change for the selected button, but if another button is pressed then to remove the background colour on the previous button and change the colour on the new button.
Sorry if this doesn't make sense
Thanks
This approach uses Toggle buttons in a list box and uses selected item binding to managed which one is toggled. This will maintain the button look and add radio button behavior:
How to get a group of toggle buttons to act like radio buttons in WPF?

dropdown selectedindexchanged issue within modalpopup extender

I'm having a dropdown in a ModalPopupExtender. The dropdown values are updated dynamically.
The problem is While clicking on the button in modal popup...The dropdown values was refreshed. So I tried to take the selected value of dropdown within the sectedindexchanged event. But If I put breakpoint with this also the control is not coming.
Can anyone tell me the fix for this?
SelectedIndexChanged is event triggered when the selection is changed, not when you change the items in the dropDown. for that you may use DataSourceChanged if you change the dataSource property or other, or other events, depend on what your code do ( please share it).

Change the Grid View Pages on button click in C# Asp.net

I have a problem that I want to change the Grid View page on button click. Means Grid View paging concept on button click in C#. I have to click on a button having a particular number text, then this will shows the particular page of gridview corresponding to the Button clicked.
Thanks in advance.
You can use the PageIndex property for that.

Dynamics controls lost on postback

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.

Tabindex for Dynamically created fields

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.

Categories