I have dropdown list in a gridview column edit template. It works OK, except
when I edit a row, the dropdown list does not initialize to the existing
value that shows in the textbox that displays in the item template. I tried
to initialize the selected value of the dropdown list with some lines of
code in the grid_RowEditing event but I get an error that I do not
understand. The error occurs at this line of code:
String DelID =
((DropDownList) grid.Rows[e.NewEditIndex].FindControl("D elDropDownList" )).Text;
the error is: "Object reference not set to an instance of an object."
I do not understand this, because code from the grid_RowUpdatin g event that
runs error-free is the same except that it uses e.RowIndex instead of
e.NewEditIndex and both indexes have the same value. Can someone shed some
light on this for me?
Thanks,
Keith 2 7786
I think (and someone please correct me if I'm wrong) but all of the
controls inside the edit item template are not created until the data
grid is bound. Also the OnRowEditing event fires before the
OnRowDataBound event. Therefore during the on row editing event the
drop down list (and anything else inside the edit item template)
doesn't exist yet.
The way I got it to work for me when I ran into this problem is to
initialize the selected value of the drop down list during the
OnRowDataBound event- not the OnRowEditing event.
The solution turned was simple: I just needed to bind the SelectedValue
property of the DropDownList to the related field in the GridView edit
template. Now that I have done that, everything works.
Thanks,
Keith
<Ma***********@ gmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com... I think (and someone please correct me if I'm wrong) but all of the controls inside the edit item template are not created until the data grid is bound. Also the OnRowEditing event fires before the OnRowDataBound event. Therefore during the on row editing event the drop down list (and anything else inside the edit item template) doesn't exist yet.
The way I got it to work for me when I ran into this problem is to initialize the selected value of the drop down list during the OnRowDataBound event- not the OnRowEditing event. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: COHENMARVIN |
last post by:
I'm leafing through a big book on asp.net, and I don't see any way to
the following:
1. bind values and text to a dropdown
2. Also make the first line of the dropdown say something different.
For instance, if I'm working with a table of hotels, I might want a
'select' control as follows
<select id="mylistbox" runat="server">
<option value="*">Add New Hotel</option>
<option value="1">The Hilton</option>
<option value="2">The...
|
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 it's a Sharepoint WebPart.
I'm trying to do something fairly simple, create a datagrid that displays
where
and when a person works and allows them to change some of the information
via DropDownLists.
When the user clicks to edit a row, three of...
|
by: P. Yanzick |
last post by:
Hello,
I've been playing with master/detail views as well as editing in the
gridview, and I ran across a strange problem that I am not exactly sure
where to go to try to solve.
I have 2 tables, a table of cars (pretty basic, an ID, a description, and a
Color ID) and a table of colors (Color ID, and a color description). I've
added a gridview and a detailsview as I'm playing with both and how to get
editing features to work the way I...
|
by: den 2005 |
last post by:
Hi everybody,
I created a Gridview with a TemplateField and there is Label control in
ItemTemplate and a DropdownList control in EditItemTemplate, I was to
displayed them ok when I click the Edit Command button. But when I about to
get the value of this template field I get an empty string value. I check the
following the local dtFiles has data and the cells are visible at stage right
before foreach GridViewRow gr in gdvFiles.Rows) loop....
|
by: AG |
last post by:
Hi,
ASP.NET 2.0 web app
I have a GridView utilizing template columns and bound to an
objectdatasource.
In the edit template of one column there is a dropdownlist bound to another
objectdatasource.
The dropdownlist displays the appropriate values when entering edit mode.
However when I try to update, I receive the following error.
| |
by: mitchman10 |
last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours
My Chargecode table has ChargecodeID,c_Text
I need an Editable datagrid that will show the
TimeID,Employee,PayPeriod,C_Text in a label and hours, along with an
edit linkbutton.
When they click on edit, the edit button turns to Update Cancel
TimeID stays read Only
|
by: lamolap |
last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel)
my gidview looks like this
Edit Surname Initials ParkingBay
CommandField Me Y dropdownlistvalue
CommandField You m dropdownlistvalue
i have 2 sqldatasource. the other one is for gridview and...
|
by: S_K |
last post by:
I have a GridView that has a DropDownList in one of the columns.
When I edit and update any row I would like to grab the SelectedValue
of that DropDownList when I'm in the GridView_RowUpdating event.
Any ideas?
|
by: arunbojan |
last post by:
Hi All,
I have an editable datagrid with 10 columns, one of those is ddl column which I used for showing the status....
By default all the columns are readonly, when user clicks edit, status ll be enabled and im getting the values in the grid.......
say, following are the values in status
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: 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...
| |