Solution Title: Datagrid Template Column Radio Button (get access to the rb control)


Hi. I have a radio button in a template column of a datagrid. All I need to know is how to get access to this to be able to set the radio button as checked or unchecked (depending on the results of a query).
I'm trying this:
Dim rbactionneeded As RadioButton = CType(e.Item.FindControl("rbactionneeded"), RadioButton)
If ansval = "Y" Then 'result from stored procedure
rbactionneeded.Checked = True
End if
(very simplified). I'm getting an error "object reference not set to an instance of an object" right when it hits rbactionneeded.checked=true. I tried add the word "new" when declaring, but didn't work. I'm certain the rb in my grid is called rbactionnneeded because I use this to insert into the database.
This code is in the itemdatabound for the given datagrid.
Any suggestions? Am I doing this incorrectly?
urgent!
Thanks!
0
micheal
3/24/2005 6:26:06 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
686 Views

Similar Articles

[PageSpeed] 44

It seems you are following the right steps.. Could you post your code - might be helpful for the troubleshooting...

Are you checking if the item type in the ItemDataBound event, before looking for the radio control?
....
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.SelectedItem Then
....
Remove "_no_spam" for sending email
0
dpl
3/24/2005 1:25:22 PM
Reply:

Similar Artilces:

How to access a template column in a datagrid control
I have a DataGrid control on a web form with a template column. How can I access the dropdownlist column "ddlusertype" from my c# code? I need to bind it with a DataTable. Please help, thanks! Here is my code <Columns> <asp:BoundColumn DataField="rolName" HeaderText="User Type"></asp:BoundColumn> <asp:BoundColumn DataField="rolDescription" HeaderText="Description"></asp:BoundColumn> <asp:BoundColumn DataField="gtyAbbr" HeaderText="Client Type"></asp:B...

how can i access a control in the edit template column of Datagrid
Hi I want to access or setfocus in a textbox control in the edit template column of a datagrid. i'm using the visual studio 2003 version. thanks for your responses..   Hi, You can browse through the following link. It might help you. http://www.syncfusion.com/FAQ/aspnet/WEB_c4c.aspx ThanksSharmila Use FindControl to get the reference of the textbox in the ItemDataBound event. TextBox tb  = (TextBox )e.Item.FindControl("TextBox1");   I'm sorry.. it doesn't worked.. i need to set focus  to a text box control used in the datagrid's edit template column.. wi...

validating the checked value of an radio button in javascript when the control is inside templates and user control???
I nee to know which radio button is selected on the client using javascript with this code it seems is how it is done: for (i=0;i<document.test.myradio.length;i++){if (document.test.myradio[i].checked==true)theone=i but my radio is a radiobuttonlist inside a usercontrol on a contentpage and all I can get to is the clientID like this: var NewAlbumEditorAJAXTypeOption = '<%= RadioButtonList1.ClientID %>' but how will I find my control and iterate thru the options?   Hi Try this code<html xmlns="http://www.w3.org/1999/xhtml"> <head runat=...

Serverside Template Control
I've created a template control what I am running into difficults is during the Page_Load event on my web page I cannot access the child controls in the two possible templates. What I would like to be able to do is set the value or make some changes to the control at runtime but I have not been successful in gaining code access to the control, for example the TEXTBOX1 control in the EditTemplate template.     Does anyone know a good way to preform this task, let alone if I am even using the correct event Example of HTML Render  <aspSample:TextLabe...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

access Radio button button in repeater control..........how?
I am displaying some records using repeater control. Each row will have a radio button. User will select one of the records and will click the submit button. Now I have some questions,1) For radio button should I use html radio button (input type=radio) OR use web server control Radio button?2) How can I access the checked radio button in either case above?thanks in advance.feed the creative machine 1. You can use either, as long as they both have runat="server". The server control gives you a more consistent programming model.2. Since the radio button will be in a template you n...

Why is my ATLAS TEMPLATED USER CONTROL getting all instances of this controls methods called? I only want it called for the instance that I click the button from...
I have created a templated user control and it uses ATLAS. So...once the control loads, it then makes an ajax call to populate itself. "server" UpdateMode="Conditional" ID="UpdatePanel1" ChildrenAsTriggers="False" > "TNews1" runat="server"> BNNews(<%# Container.Row["TotalItems"].ToString()%>) <%# Container.Row["NewsID"] %> - "BNP35.aspx?newsId=<%# Container.Row["NewsID"]%>&promoId=<%# TN...

How to access a child control in a templated control?
I am not sure how to access a child control that I addes to a templated control. For example: I drag a Login Control (ID: "Login1") into page in VisualStudio web developer, I can click on it and from the upper right of that control now in my desinger I can choose "convert to template".  Now I can drop in my own control to be added to the Login Control.  Let say I drag over a DropDownList control (ID: "DropDownList1") and place it at the bottom within the Login Control. At run time I might expect to access the my DropDownList control with somethin...

Radio button controls and Validation control
Hi, I have a group of radio button controls. I want to force user to selecte one those. If not, show a message. I tried to use a RequiredFieldValidator, but ControlToValidate shows nothing. I can check each radio button and check if any is selected, but am sure there is a smarter way. Maybe using a validator. Would you let me know? Thank you, J required field validator validates some inputs like date, integer, string .  you cannot validate the checkbox using a requiredfield validator.Got what you needed. Please mark as answer. Well, they are radiobutto...

Accessing Child Controls of a Template Server Control
I've created a templated control that has a property called ContentTemplate which is of type ITemplate.  The control works great with the exception of I now have to interact with the child controls via the FindControl method. Markup: <test:MyControl ID="testControl" runat="server"> <ContentTemplate> <asp:Label ID="testLabel" runat="server" /> </ContentTemplate> </test:MyControl>    In order to interact with the child label, testLabel, I now need to do something like this:Dim lbl As La...

Accessing controls inside User control template
Hi, I need to create a user control with one template. That template needs to be like View in MultiView or Wizzard control or Panel. It means, that controls, which are inside should be visible to the page. It will be created just once per control. I need to be able to write :  TextBox1.Text = "Hello world" not : (MyUserControl1.Controls.FindControl("TextBox1") as TextBox).Text = "Hello world" Thanks, radco  If this is a answer to your problem, mark it as answer in right upper corner. It helps other who read your article to known that...

Cannot access the controls of a page found in a datagrid control
Hello All,I am trying to access the RadioButtonList controls of an aspx page using this code: ..........................................................................................................Dim ctl As ControlDim answers As ArrayListFor Each ctl In Page.Controls(1).Controls   If TypeOf ctl Is RadioButtonList Then       If not CType(ctl, RadioButtonList).SelectedItem Is Nothing Then          Try          answers.Add(CType(ctl, RadioButt...

Access controls in Wizard control header template.
Is this possible?Web dev - spending forever achieving nothing. hi, suppose the control in the header template is a DDL with Id DropDownList1 access it this way DropDownList dp = (DropDownList)Wizard1.FindControl("headerContainer$DropDownList1");        Response.Write(dp.SelectedValue); hope it helpsJessica CaoSincerely,Microsoft Online Community Support“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community ...

Accessing web controls from within a DataGrid control
Hi, Could someone tell me how to access other web controls from within a datagrid control? I have a ListBox control in a DataGrid, but can't figure out how to set the ListBox's datasource from the code behind. Any help would be great appreciated. Thanks. With the DataGrid you have the ItemDataBound event, where you can find any web control that were added to it, for each row listed in the DataGrid. Ex: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound If e.Item....

Web resources about - Solution Title: Datagrid Template Column Radio Button (get access to the rb control) - asp.net.presentation-controls

Solution - Wikipedia, the free encyclopedia
In chemistry , a solution is a homogeneous mixture composed of only one phase . In such a mixture, a solute is a substance dissolved in another ...

CHOGM climate change: Turnbull to push hi-tech solutions to drive global zero-emissions deal - AdelaideNow ...
SUPERCHARGED batteries and other hi-tech solutions will drive Australia’s carbon emissions down, Prime Minister Malcolm Turnbull will tell world ...

Syrian President Bashar al-Assad's participation necessary to find peaceful solution
The West doesn't have a good track record in toppling Middle Eastern dictators. Bashar al-Assad is part of the solution to defeating Islamic ...

CHOGM climate change: Turnbull to push hi-tech solutions to drive global zero-emissions deal
SUPERCHARGED batteries and other hi-tech solutions will drive Australia’s carbon emissions down, Prime Minister Malcolm Turnbull will tell world ...

New glasses promise a solution to colour blindness
The inventors of a brand of glasses called EnChroma say they have found a fix to colour blindness that is helping to bring the colour back into ...

Apple acknowledges issue with iPad Pros, but no solution yet
... your iPad Pro up as new or restored it from a backup. In a brief support document , Apple has acknowledged the problem. So far, the only solution ...

With traffic fatalities rising, safety officials see tech as cause and solution
(credit: Jason Weaver ) The National Highway Traffic Safety Administration (NHTSA) released numbers on Tuesday showing a slight decrease in ...

Dell announces Datacenter Scalable Solutions server line
... as oil and gas, and research institutions. Dell hopes to meet the unique needs of companies in these fields with its Datacenter Scalable Solutions ...

"But before he replaced the 'bone flap'—the section of skull that is removed to allow access to the brain—he ...
"Then he reattached it to Egan’s skull, using tiny metal plates and screws. Muizelaar hoped that inside Egan’s brain an infection was brewing.... ...

A Message For Our Republican Amigos Christie? Trumpf? There's A Better Solution To Your Anguish
Artist Darkblack foresees a Jersey Bounce in New Hampshire The funnest news Saturday night was the announcement that New Hampshire's Union Leader ...

Resources last updated: 12/1/2015 12:47:42 AM