468,272 Members | 2,035 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

OnEditCommand - .FindControl Returning Null

cross posted in datagrid group.

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";

Nov 17 '05 #1
0 1963

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by George Durzi | last post: by
6 posts views Thread by Chris Fink | last post: by
reply views Thread by Tim::.. | last post: by
2 posts views Thread by tparks69 | last post: by
14 posts views Thread by =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.