473,569 Members | 2,813 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:templateco lumn HeaderText="To Be Completed By">
<itemtemplate >
<asp:Label runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.FULL_ NAME") %>'><asp:label >
</itemtemplate>
<edititemtempla te>
<asp:dropdownli st ID="cboToBeComp letedBy"
Runat="server"> </asp:dropdownlis t>
</edititemtemplat e>
<asp:templateco lumn>

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

dgStatusIncompl ete.EditItemInd ex = e.Item.ItemInde x;
FetchSurveyStat usIncomplete(); // Populates the DataGrid
FetchUsersbyDep artment(
e.Item.Cells[2].FindControl("c boToBeCompleted By"),
e.Item.Cells[3].Text.ToString( ));
The problem is that e.Item.Cells[2].FindControl("c boToBeCompleted By") is
returning null, so the FetchUsersbyDep artment isn't receiving the drop down
list control as a parameter, it is incorrectly receiving null as a
parameter. Any idea?
private void FetchUsersbyDep artment(object control, string DeptId)
{
// Fetch Users for the Department
DataSet dsStaff = Department.Fetc hUsersbyDepartm ent(ConnectStri ng,
DeptId);

System.Web.UI.W ebControls.Drop DownList ctrl =
(System.Web.UI. WebControls.Dro pDownList)contr ol;

using (dsStaff)
{
if (dsStaff.Tables[0].Rows.Count > 0)
{
ctrl.DataSource = dsStaff;
ctrl.DataTextFi eld = "USER_NAME" ;
ctrl.DataValueF ield = "ID";
ctrl.DataBind() ;
}
}
}

Nov 17 '05 #1
0 2186

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 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.FULL_NAME") %>'><asp:label> </itemtemplate> <edititemtemplate>
6
7951
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 the debugger and after I am done drilling down 10 levels deep I still can't easily tell where the control lives... ====CODE BEHIND==== using...
0
1060
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 DataGridCommandEventArgs) If e.Item.Cells(0).Controls.Count > 0 Then ' Edit Link
2
3174
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 FindControl to set a reference to the img control so I can change the attribute. But when I run the code below I get the error: "Object reference...
0
1153
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 OnEditCommand event is raised, I try to do the following: 1. Find the selected datalist item in which the nested datagrid raised the event. (by...
0
1686
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 OnEditCommand event is raised, I try to do the following: 1. Find the selected datalist item in which the nested datagrid raised the event. (by...
1
2867
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 returning NULL THUS I m getting exception "Object Refrence not set to an Instance to Object", Here is the code I wrote (ASP.NET 1.1)...
0
1427
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. This text is inserted into a text field in an SQL server. When the data is read and presented by the datalist, the line breaks are gone. All the...
14
3186
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 within my Default.aspx as follows: MyUC C = (MyUC)this.FindControl("SomeID"); When I try to run this, I get error: "The type or namespace name...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.