473,857 Members | 2,017 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 2209

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
7971
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 System; using System.Collections; using System.ComponentModel;
0
1070
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
3186
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 not set to an instance of an object." I assume its not finding the control and returning null? ...
0
1169
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 calling getDataGridReference and returning the DataList's selectedIndex)
0
1706
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 calling getDataGridReference and returning the DataList's selectedIndex)
1
2883
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
1440
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 text is just together without paragraphing. I am able to keep the spaces if I try this approach:
14
3212
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 'MyUC' could not be found (are you missing a
0
9923
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9767
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10709
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10394
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9544
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
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
2
4189
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3214
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.