Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > OnEditCommand - FindControl returning Null

Thread Tools

OnEditCommand - FindControl returning Null

George Durzi
Posts: n/a
Inside <columns/> in my datagrid, I have the following template column

<asp:templatecolumn HeaderText="To Be Completed By">
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.FULL_NAME") %>'><asp:label>
<asp:dropdownlist ID="cboToBeCompletedBy"

this template column is in cell 2 (0,1,2)

In my EditCommand event, I'd like to populate this dropdownlist. I call this

dgStatusIncomplete.EditItemIndex = e.Item.ItemIndex;
FetchSurveyStatusIncomplete(); // Populates the DataGrid

The problem is that e.Item.Cells[2].FindControl("cboToBeCompletedBy") is
returning null, so the FetchUsersbyDepartment isn't receiving the drop down
list control as a parameter, it is incorrectly receiving null as a
parameter. Any idea?

private void FetchUsersbyDepartment(object control, string DeptId)
// Fetch Users for the Department
DataSet dsStaff = Department.FetchUsersbyDepartment(ConnectString,

System.Web.UI.WebControls.DropDownList ctrl =

using (dsStaff)
if (dsStaff.Tables[0].Rows.Count > 0)
ctrl.DataSource = dsStaff;
ctrl.DataTextField = "USER_NAME";
ctrl.DataValueField = "ID";

Reply With Quote

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
FindControl on GridView Cell returning null saha ASP .Net 0 06-25-2006 06:50 PM
OnEditCommand : Nested DataGrid referencing : Code included Chris ASP .Net 0 01-24-2006 06:14 PM
Problem Referencing OnEditCommand: Index out of Range ElGordo ASP .Net 0 01-24-2006 02:33 PM
OnEditCommand =?Utf-8?B?VGltOjouLg==?= ASP .Net 0 01-24-2005 02:05 PM
OnEditCommand - .FindControl Returning Null George Durzi ASP .Net 0 07-14-2003 09:54 PM