Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > onedit method

Reply
Thread Tools

onedit method

 
 
John H
Guest
Posts: n/a
 
      09-27-2004
I have a datagrid that is bound to a database table. One field in the table
is gender. When my datagrid first renders the Gender column shows "Male" or
"Female". When I click Edit the Gender column displays 2 radio buttons so
you can choose male or female.

The thing is, I want to ensure that the correct radio button is "checked"
depending on the database value.

I thought it would be easy to do this by adding some extra code into the
Datagrids EDIT method so that when the user clicks on the edit link, my edit
method could access the database and if the gender field is male the rbMale
radio button is checked else the rbFemale button.

However, I can't access controls that are held in the <EditItemTemplate>
section from the edit method. I can use the FindControl method to find
controls by their ID that are in the <ItemTemplate></ItemTemplate> tags but
I can't use it to access controls in the
<EditItemTemplate></EditItemTemplate> tags.

For example, I can find the label and thus the text that is in the
<ItemTemplate> section like this:
Label gender = (Label)e.Item.FindControl("lblGender");
string genderText = gender.Text;

If I try to access a control in the EditItemTemplate the same way, it can't
find it. It has no problem finding these values from my update method when
an update event is fired though.

It's as though when an edit event fires you can only access the controls in
the <ItemTemplate> section which is odd because the controls in the
<EditItemTemplate> are displayed on the screen.

I must be getting mixed up with the scope of the whole thing but I can't
figure it out.

Any ideas would be most welcome.

Thanks in advance

John





 
Reply With Quote
 
 
 
 
Joel Cade, MCSD
Guest
Posts: n/a
 
      09-27-2004
It may be easier using a radiobutton list, rather than individual radio
buttons. If you do this, then the edit command would only need to gain
access to the one control (using
CType(e.Item.Cells(iRadioCell).Control(0),
RadioButtonList).SelectedIndex).

Hope this helps!


Joel Cade, MCSD .Net, MCAD, MCP
Fig Tree Solutions, LLC
http://www.figtreesolutions.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
John H
Guest
Posts: n/a
 
      09-27-2004

<Joel Cade>; "MCSD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It may be easier using a radiobutton list, rather than individual radio
> buttons. If you do this, then the edit command would only need to gain
> access to the one control (using
> CType(e.Item.Cells(iRadioCell).Control(0),
> RadioButtonList).SelectedIndex).
>

Hi Joel thanks for your reply.

I couldnt even access a textbox from <EditItemTemplate>.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
method def in method vs method def in block Kyung won Cheon Ruby 0 11-21-2008 08:48 AM
invoke a method by reflection£¨the method's parameters can not be ArrayList? jerry051 ASP .Net 2 08-02-2005 10:35 AM
BC30289: Statement cannot appear within a method body. End of method assumed. Carlos Oliveira ASP .Net 0 08-19-2004 07:51 PM
Difference between Delete method and RemoveRow method CW ASP .Net 0 04-01-2004 01:07 AM
ASP.NET: BC30289: Statement cannot appear within a method body. End of method assumed. Mike Wilmot ASP .Net 0 12-15-2003 07:49 PM



Advertisments