473,396 Members | 2,010 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,396 software developers and data experts.

How to access dropdownlist inside iTemplate?

Hello,

I am adding columns to the datagrid programmatically. And I have
created a countries drop down list in an ascx file. I have added the
countries drop down list to the datagrid column as follows,

TemplateColumn tc = new TemplateColumn();
ITemplate iTemplate = LoadTemplate("DropDownList_Countries.ascx");
tc.EditItemTemplate = iTemplate;
DataGrid1.Columns.Add(tc);

The drop down list has been loaded successfully on the datagrid. And
now I want to set it to a value (according to the database binding).
Say, set to the value of Norway.

I have tried this but not successful:

DropDownList ddlCountry = (DropDownList)
DataGrid1.FindControl("DropDownListObject");
ddlCountry.SelectedValue = "Norway";

The error is "System.NullReferenceException: Object reference not set
to an instance of an object." (Probably the control cannot be found)

How can I access the dropdownlist object inside the iTemplate and set
its value?

I was looking into the instantiateIn method, but not sure how to fit
this into my case.

Thanks a lot.

Nov 19 '05 #1
0 1699

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

Similar topics

0
by: Andy Eshtry | last post by:
Hello Dear Professionals: Based on this document: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingwebservercontroltemplatesdynamically.asp or this...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
0
by: cosine... zero | last post by:
<select id="ZoneID" Multiple=False DataSource=<%# UserList.DataSource.Tables("Zones") %> DataTextField="NewsZoneText" DataValueField="NewsZoneID" value=<%# Container.DataItem("NewsZoneID") %>...
0
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
2
by: glenn | last post by:
Hi folks, Page_Load has the following definition: Sub Page_Load(sender as Object, e as EventArgs) As such, we are unable to instantiate a control that is inside a DataGrid since the e...
4
by: Sevu | last post by:
I am working with ASP.NET.I am using ReportViwer Control to show my report.I like to add dropdownlist with in the reportviewer control. ( Not top to the control some thing like that).I need to...
5
by: Ben Schumacher | last post by:
Ok smart guys and gals ... I have a GridView control with a dynamically created checkbox column. The checkbox is created using ITemplate interface. In my class that implements the ITemplate...
3
by: Brian VanDyke | last post by:
I have to display a table with customer data (GridView). However, I want to be able to show DropDownList controls inside one of the columns, not just textbox controls. Is this possible? Is it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.