• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 625
  • Last Modified:

DetailsView trying to find controls

I am trying to find controls in a detailsview so that I can update a table. The code is currently running in the ItemCommand event, but I'm open to moving it if needed. So basically I have some controls inside itemtemplate sections and I need to get their values so that a buttonfield can set my updates into a table. Basically the controls are not being found.
foreach (DetailsViewRow item in dvTickets.Rows)
                {
                    _ddlApproverStatus = (DropDownList)item.Controls[0].Controls[0].FindControl("ddlApproverStatus");
                    if (_ddlApproverStatus != null)
                    {
                        status = _ddlApproverStatus.SelectedIndex;
                    }
                    _txtbApproval = (TextBox)item.Controls[0].Controls[0].FindControl("txtbApproval");
                    if (_txtbApproval != null)
                    {
                        approvalComment = _txtbApproval.Text;
                    }
                    _txtbPending = (TextBox)item.Controls[0].Controls[0].FindControl("txtbPending");
                    if (_txtbPending != null)
                    {
                        pendingComment = _txtbPending.Text;
                    }
                    _txtbRejected = (TextBox)item.Controls[0].Controls[0].FindControl("txtbRejected");
                    if (_txtbRejected != null)
                    {
                        rejectedComment = _txtbRejected.Text;
                    }
                }

Open in new window

0
dharric08
Asked:
dharric08
  • 3
  • 3
1 Solution
 
guru_samiCommented:
I hope this article should help you:
http://www.aspdotnetcodes.com/Parent_Child_GridView_DetailsView.aspx

You should try using ItemUpdating / ItemInserting etc event.
0
 
jorge_torizCommented:
If you use item.FindControl("")?
0
 
dharric08Author Commented:
jorge,
I've tried doing that and several other variations like myDetailView.findcontrol. I've been reading some articles and it appears that at the time that my button's event is occuring the data items do not exist yet. I was hoping there was a work around other than using the detailview's insert and edit properties.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jorge_torizCommented:
If they do not exist, can you call dataBind method before your current code?
0
 
dharric08Author Commented:
The point is to call during. As I'm trying to run it on a click event for a button.
0
 
jorge_torizCommented:
Where is the button?, inside your detailsView?... you can call dataBind in your button code
0
 
dharric08Author Commented:
I gave up. I'm using a dynamic table now.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now