473,508 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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">
<itemtemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.FULL_NAME") %>'><asp:label>
</itemtemplate>
<edititemtemplate>
<asp:dropdownlist ID="cboToBeCompletedBy"
Runat="server"></asp:dropdownlist>
</edititemtemplate>
<asp:templatecolumn>

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

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

dgStatusIncomplete.EditItemIndex = e.Item.ItemIndex;
FetchSurveyStatusIncomplete(); // Populates the DataGrid
FetchUsersbyDepartment(
e.Item.Cells[2].FindControl("cboToBeCompletedBy"),
e.Item.Cells[3].Text.ToString());
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,
DeptId);

System.Web.UI.WebControls.DropDownList ctrl =
(System.Web.UI.WebControls.DropDownList)control;

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

Nov 17 '05 #1
0 2169

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
698
by: George Durzi | last post by:
cross posted in datagrid group. Inside <columns/> in my datagrid, I have the following template column <asp:templatecolumn HeaderText="To Be Completed By"> <itemtemplate> <asp:Label...
6
7930
by: Chris Fink | last post by:
In the below example could someone please assist in why the findcontrol method is returning null. Is there are easy way to determine where in the page heirarchy a control exists - I currently use...
0
1055
by: Tim::.. | last post by:
Why doesn't my onEditCommand work??? I don't get an error it just doesn't do the page redirect as requested... Thanks ...CODE.. Sub LinkButton_OnClick(ByVal sender As Object, ByVal e As...
2
3171
by: tparks69 | last post by:
All I need to do is set the border property of an image control to border=0. I want to do this at runtime for the first image on the page in a datalist. In the ItemCreated event I'm trying to use...
0
1148
by: ElGordo | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
0
1678
by: Chris | last post by:
I've been searching all over and think I am close, but keep getting the error "Index out of range" when trying to reference a nested datagrid when an OnEditCommand event is raised. When the...
1
2861
by: Anup | last post by:
Hi Group, I have a datagrid with dropdown in my application. I want to fill the data in dropdown by an ArrayList for that I am using "e.Item.FindControl("DropdownId")" but this function is...
0
1425
by: Jim in Arizona | last post by:
Is there an easier way to make a datalist aware of line breaks within text fields? I have a text box that users can type into. If they press the enter key a few times, VB sees this as a vbCrLf....
14
3181
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of that control on a Page ("Defaul.aspx"). The control works fine. Now, I want to be able to use "FindControl()" from...
0
7114
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.