473,795 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

(v2003) Datagrid Dropdownlist Edit Problems

bh
I'm trying to edit data in a datagrid through a dropdown list with different
id/text values. The problem comes in when I click the edit button & nothing
appears to be happening. Did I do something wrong in the EditItemTemplat e
or should I be binding, somehow, separately in the vb code? Please view my
code, below, and the notes in green for clarification of what I've done, and
what is/is not working, here. Thanks in advance.

<asp:DataGrid id="dgItems" runat="server" CssClass="table standardsetting s"
BorderColor="Na vy" AutoGenerateCol umns="False">

<Columns>

<asp:TemplateCo lumn HeaderText="Ava ilable Items">

<ItemTemplate 'This works

<asp:Label
id="lbItem" runat="server" Text='<%# DataBinder.Eval (Container.Data Item,
"ItemName") %>' />

</ItemTemplate>

<EditItemTempla te 'This
does not work

<asp:DropDownLi st
id="cboItem" runat="server"

DataSource='<%# dvItems %>'

DataTextField=" ItemName"

DataValueField= "ItemID">

</asp:DropDownLis t>

</EditItemTemplat e>

</asp:TemplateCol umn>

<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="OK"
CancelText="Can cel" EditText="Edit" />

<asp:ButtonColu mn Text="Delete" CommandName="De lete"/>

</Columns>

</asp:DataGrid>

'----------------------------------------------------------

'I bind & display the datagrid here, when a user checks a

'box to maintain the items - THIS PART WORKS

'The grid is displayed, & the items show in the item column

'----------------------------------------------------------

Private Sub chkItems_Checke dChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles chkItems.Checke dChanged

If Me.chkItems.Che cked Then

Me.BindItemsToG rid()

Me.pnlItemMaint enance.Visible = True

Else

Me.pnlItemMaint enance.Visible = False

End If

End Sub

'----------------------------------------------------------

'However, when edit is selected, the dataview is populated,

'but the row never opens in edit mode (the drop-down list

'and Update/Cancel Buttons are not displayed/opened).

'----------------------------------------------------------

Private Sub dgItems_EditCom mand(ByVal source As Object, ByVal e As _

System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgItems.EditCom mand

BindItemsDropDo wnList() 'Populates dvItems - This works

Dim lblItemLabel As Label = e.Item.FindCont rol("lblItem")

Session("OldIte m") = lblItemLabel.Te xt

'----------------------------------------------------------

'Tracing accurately shows information retrieved from the Dataview,

'That should be bound to the data grid's dropdownlist

'----------------------------------------------------------

Trace.Write("Cu rrent Item: " & Session("OldIte m"))

Trace.Write("ID : " & CStr(dvItems.Ta ble.Rows(e.Item .ItemIndex)("It emID")))

Trace.Write("It em: " &
CStr(dvItems.Ta ble.Rows(e.Item .ItemIndex)("It emName")))

'----------------------------------------------------------

'HERE ARE THE TROUBLESOME PARTS:

'----------------------------------------------------------

'1) Setting the properties of the actual cboItem

'dropdownlist in the grid: The following 2 lines generate

'an instantiation error, but if I create an instance, then

'it's separate from the actual item in the grid.

'

'Dim cboItemList As DropDownList = e.Item.FindCont rol("cboItem")

'cboItemList.Se lectedItem.Text = lblItemLabel.Te xt

'----------------------------------------------------------

'2) Row never opens for editing (even with above 2 lines

' removed):

'----------------------------------------------------------

Me. dgItems.EditIte mIndex = e.Item.ItemInde x

End Sub
Oct 19 '06 #1
0 1204

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

Similar topics

3
4273
by: Bill C. | last post by:
Hello, I know this has been discussed a lot already because I've been searching around for information the last few weeks. I'm trying to implement a DataGridComboBoxColumn class. I've found several examples on the web. They all seem to have problems, though that I've been unable to resolve. The most promising example I have found is at:
0
1491
by: Wayneb | last post by:
Hi I have a datagrid with autogenerates columns based upon a dataset I have constructed from the results of database query - pretty noddy stuff. When you click on Edit I remove the standard Textboxs you get with the Edit command and replace a number of they with DropDownLists. I have to do this programatically and not via asp template columns becuase the number of columns can vary. The DropDownLists I create are show in the datagrid...
7
4226
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now the first item in the dropdown is always displayed. Template Code: <asp:TemplateColumn HeaderText="DropDown"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval
1
4341
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch the layout, some have child controls):
10
1909
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain column that I need to populate while in Edit Mode. Two questions: Is there a way to directly use another DropDownList as a DataSource? If so how? I'm using the following code to try to populate the DropDownList, but
0
1833
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...
1
2370
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .. http://sf-f.org, weblog and search engine for fans and writers of
2
1733
by: Frank | last post by:
Hello, I am developing with VS.Net 2003 on the asp 1.1 platform. I am a few days new to using a datagrid. I found a nice tutorial and had no problems using an editable datagrid with textboxes and an additional buttoncolumn where I used a delete button to delete a specific row. Once I had finished that, I trnsformed the grid tso it will display a dropdownlist indtead of a textbox. After much grappling, I pretty much have
6
5746
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
0
9519
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
10213
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
10000
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
9040
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...
1
7538
isladogs
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...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
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...
1
4113
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
3
2920
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.