473,322 Members | 1,287 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,322 software developers and data experts.

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 19 '05 #1
4 1157
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 19 '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 19 '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 19 '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 19 '05 #5

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

Similar topics

1
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...
5
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
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
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
2
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
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
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
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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

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.