473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 2155

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

Similar topics

0
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
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
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
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
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
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
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
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.