473,659 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with DropDown in EditItem of Datagrid!

Hello!

When you Click Edit of a DataGrid row I, in EditCommand sub, set the right
Index and recnid the DataGrid.

In ItemCreated (of that Bind) I fill a DropDownlist ( buy adressing it with
ItemIndex and FindControl) and set the Selected Value to the Value I want.
So Far everything is Fine, if I debug and step thru the code.. it fills and
the Selected Value is the right value.

But Then when the page shows... the Selected Item is not the Item with the
SelectedValue.. it's the first in the DropDown box.. as if nothing was
selected. But the Dropdownbox is filled with the right stuff, just not
selected with the value I set (and saw in the debug that it was set)

Since this is VB I can't debug the Data Itself so I tried Setting a
breakpoint in EVERY function and Sub I had in the Form and se if the
DropDownlist accidentley resetted somehow somewhere.. but I can't really
find any place where the Selected Value is overwritten or anything---

I have no idea where to look for answers now.. please help!

Best Regards
/Lars
Nov 18 '05 #1
1 1186
They actually tell how to do it here..

http://aspnet.4guysfromrolla.com/art...80702-1.3.aspx

But It's strange to me that they do it in the HTML and not in ItemCreated..
I guess it has to do in what order things happen... an dI guess ItemCreated
in not the right tiem to set the SelectedIndex..

I got it working though, with their technique...

/Lars
"Lars Netzel" <[stop_spam]@host.topdomain > skrev i meddelandet
news:uE******** *****@TK2MSFTNG P11.phx.gbl...
Hello!

When you Click Edit of a DataGrid row I, in EditCommand sub, set the right
Index and recnid the DataGrid.

In ItemCreated (of that Bind) I fill a DropDownlist ( buy adressing it with ItemIndex and FindControl) and set the Selected Value to the Value I want.
So Far everything is Fine, if I debug and step thru the code.. it fills and the Selected Value is the right value.

But Then when the page shows... the Selected Item is not the Item with the
SelectedValue.. it's the first in the DropDown box.. as if nothing was
selected. But the Dropdownbox is filled with the right stuff, just not
selected with the value I set (and saw in the debug that it was set)

Since this is VB I can't debug the Data Itself so I tried Setting a
breakpoint in EVERY function and Sub I had in the Form and se if the
DropDownlist accidentley resetted somehow somewhere.. but I can't really
find any place where the Selected Value is overwritten or anything---

I have no idea where to look for answers now.. please help!

Best Regards
/Lars

Nov 18 '05 #2

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

Similar topics

7
4212
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
6
5393
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I am receiving errors when trying to set the selected value of the dropdown within the ItemDataBound() subroutine. Below is the code I am using. I hope someone can tell me if this is possible. '''HTML''' <asp:datagrid id="dgAssignments"...
1
1173
by: Tim::.. | last post by:
Can someone please tell me who I get the selectedindex of a dropdown in a datagrid??? I have the following code and it works but it doesn't select the correct value when I edit the dropdown list! Thanks Dim Myconn As New
1
1157
by: Kurt Schroeder | last post by:
I have a datagrid that includes a dropdown in an edit template. It creates ok, but i'm not sure how to set the selectedvalue based on the table in the dataset. given that the dataset DsSubTypes1 what is the best way to get the current value. If it can be taken from the datagrid i'd like to know how. My sub to populate the dropdownlist is below. thanks kes If e.Item.ItemType = ListItemType.EditItem Then Dim thsddl As DropDownList =
2
5853
by: Steve Pierce | last post by:
I am having some issues with a runtime dropdownlist in a datagrid. The issue is that I cannot get ViewState to fill the selected index of a runtime dropdown properly on postback. I do not want to use template columns as they seem to be a little difficult to create at runtime. Any assistance would be very greatly appreciated. private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if...
7
3338
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid, theres a requirement to show a drop down menu list (this is a control I downloaded online) in one of the columns. For the purposes of this question, Ive implemented the drop down menu as a drop down list instead. Ive got all this working at this...
0
1827
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
1442
by: thebison | last post by:
Hi all, I hope someone can help with this relatively simple problem. I am building a timesheet application using ASP.NET C# with Visual Studio 2003.As it is only a protoype application, my database has been made in MSDE. I have a DataGrid, and have inserted a delete link button into it through Property Builder. My Delete method works fine, however I would like to insert a JScript popup to confirm, as otherwise users can just
2
2125
by: yasodhai | last post by:
Hi, I used a dropdown control bind to a datagrid. <EditItemTemplate> <asp:DropDownList ID="FldType_edit" Runat="server" DataSource='< %#GetFieldType()%>' DataTextField="Type" /> </EditItemTemplate> The values for the datagrid are retrieved from the database using the GetFieldType function
0
8339
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
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8751
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
7360
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...
0
5650
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
4176
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...
0
4338
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1982
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.