473,487 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DropDownList in DataGrid EditMode

In my webproject i have a datagrid.. i added a DropDownList in the edit mde
and in the Datagrrd1_ItemDataBound i bind data from dataview using:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
DropDownList list = (DropDownList)Datagrid1.FindControl("myddl");
list.DataSource = dv;
list.DataTextFeild= "Name";
list.DataValueFeild = "ID";
list.DataBind();

but i got and "object refrence not set to an instance of an object"
Exception..
it seem it's try to bind data b4 creating the DropDownlist itself!!

i add another Dropdownlist outside the grid which use the same Datasource
and it's wrk perfectly.

Nov 17 '05 #1
5 3563
You have to create the control to which you are binding.
Like 'list' in your case.
"Islam Elkhayat" <Is******@SaveMyPrivacy.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
In my webproject i have a datagrid.. i added a DropDownList in the edit
mde and in the Datagrrd1_ItemDataBound i bind data from dataview using:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
DropDownList list = (DropDownList)Datagrid1.FindControl("myddl");
list.DataSource = dv;
list.DataTextFeild= "Name";
list.DataValueFeild = "ID";
list.DataBind();

but i got and "object refrence not set to an instance of an object"
Exception..
it seem it's try to bind data b4 creating the DropDownlist itself!!

i add another Dropdownlist outside the grid which use the same Datasource
and it's wrk perfectly.

Nov 17 '05 #2
is this a web user control you're developing? i vaguely recall a call
that I've had to make in the past, under similar circumstances, to
assert that the control has been created. sorry I can't remember off
hand

Nov 17 '05 #3
sure i did add a dropdownlist control to a Template column in the edit item
template..
is there a way to fix the error?
thanx
"Vaibhav" <co************@yahoo.com> wrote in message
news:ex**************@TK2MSFTNGP14.phx.gbl...
You have to create the control to which you are binding.
Like 'list' in your case.
"Islam Elkhayat" <Is******@SaveMyPrivacy.com> wrote in message
news:ui**************@TK2MSFTNGP10.phx.gbl...
In my webproject i have a datagrid.. i added a DropDownList in the edit
mde and in the Datagrrd1_ItemDataBound i bind data from dataview using:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
DropDownList list = (DropDownList)Datagrid1.FindControl("myddl");
list.DataSource = dv;
list.DataTextFeild= "Name";
list.DataValueFeild = "ID";
list.DataBind();

but i got and "object refrence not set to an instance of an object"
Exception..
it seem it's try to bind data b4 creating the DropDownlist itself!!

i add another Dropdownlist outside the grid which use the same
Datasource and it's wrk perfectly.


Nov 17 '05 #4
are you sure you have the ONITEMDATABOUND="Datagrrd1_ItemDataBound" set in
the html? your code is all fine.

"Islam Elkhayat" wrote:
In my webproject i have a datagrid.. i added a DropDownList in the edit mde
and in the Datagrrd1_ItemDataBound i bind data from dataview using:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
DropDownList list = (DropDownList)Datagrid1.FindControl("myddl");
list.DataSource = dv;
list.DataTextFeild= "Name";
list.DataValueFeild = "ID";
list.DataBind();

but i got and "object refrence not set to an instance of an object"
Exception..
it seem it's try to bind data b4 creating the DropDownlist itself!!

i add another Dropdownlist outside the grid which use the same Datasource
and it's wrk perfectly.

Nov 17 '05 #5
are you sure you have the ONITEMDATABOUND="Datagrrd1_ItemDataBound" set in
the html? your code is all fine.

"Islam Elkhayat" wrote:
In my webproject i have a datagrid.. i added a DropDownList in the edit mde
and in the Datagrrd1_ItemDataBound i bind data from dataview using:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
DropDownList list = (DropDownList)Datagrid1.FindControl("myddl");
list.DataSource = dv;
list.DataTextFeild= "Name";
list.DataValueFeild = "ID";
list.DataBind();

but i got and "object refrence not set to an instance of an object"
Exception..
it seem it's try to bind data b4 creating the DropDownlist itself!!

i add another Dropdownlist outside the grid which use the same Datasource
and it's wrk perfectly.

Nov 17 '05 #6

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

Similar topics

1
1223
by: Arno | last post by:
Hi I am using a dataset to populate a editable datagrid. When I apply a table style however, the datagrid seems to become read-only... How can I make the datagrid editable again? Is there a method...
2
16974
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...
4
1159
by: Islam Elkhayat | last post by:
In my webproject i have a datagrid.. i added a DropDownList in the edit mde and in the Datagrrd1_ItemDataBound i bind data from dataview using: if (e.Item.ItemType == ListItemType.Item ||...
2
3093
by: Jeff User | last post by:
Hi C# .NET1.1 I have read Visual Studio help and several articles on the web. Obviously this is a common topic. However, I see this code over and over yet I am stuck with the FindControl method...
15
3075
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...
4
12898
by: J055 | last post by:
Hi I thought I was trying to do something very simple but I'm have a lot of trouble trying to do the following. <asp:FormView ID="fvGroups" runat="server" DataKeyNames="GroupID"...
0
1427
by: Jayant Solanki | last post by:
i have a problem with edit mode in datagrid. i have a calculation field in datagrid in which i want to do auto caluclation of "Total Fees" after updating the Amount and Rate. so how can i use...
0
1857
by: Fabrizio | last post by:
Hi all. I have a field in a gridview as templatefield which is a label in view mode and a dropdownlist in edit mode with his datasource. This gridview is inserted as templatefield in another...
0
1457
by: Dan | last post by:
Hi, I have a detailsview with two fields: in editmode, one is a textbox and the other is a dropdownlist. i want to update both fields using the detailsview. My problem: when clicking on the...
0
7106
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
7137
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
7181
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
7349
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
5442
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,...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
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 ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
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.