473,466 Members | 1,294 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Editing a dropdown

Hi,
I'm having real trouble trying to figure out how to change the selectedIndex
of a drop down list that sits in the Edit Template of a datagrid bound to a
dataset.

I get the DataValueField and DataTextField coming in fine from a l table
generated dataSet. When I want to edit the dropdown I want a dropdown to be
displayed. So am doing the SelectedIndex property for it.
So, I am trying to call a function from within the SelectedIndex property of
the asp:DropDownList. My function(GetSelectedIndex) takes one argument - an
int which it will then compare with the table and return an integer. I tried
passing that through as the argument to GetSelectedIndex() but I get the
following error:

The best overloaded method match for
'MaintenanceScreen.Screen.GetSelectedIndex(int)' has some invalid arguments
Here is the code on the page:

<ASP:TEMPLATECOLUMN HeaderText="Order">
<HEADERSTYLE FONT-BOLD="True" BACKCOLOR="#EDEAE7"></HEADERSTYLE>
<ITEMTEMPLATE>
<%# DataBinder.Eval(Container.DataItem,"DisplayOrder") %>
</ITEMTEMPLATE>
<EDITITEMTEMPLATE>
<ASP:DROPDOWNLIST ID="ddlOrder" runat="server" CssClass="label242"
Height="20" Width="40" Font-Size="12px"
DataValueField="DisplayOrder"
DataSource='<%# dsOrder %>' SelectedIndex='<%#
GetSelectedIndex(DataBinder.Eval(Container.DataIte m,"DisplayOrder")) %>'
AutoPostBack="True"
OnSelectedIndexChanged="dgDetailsDropDown_Selected IndexChanged">
</ASP:DROPDOWNLIST>
</EDITITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>

and here is the method on the codeBehind:

protected int GetSelectedIndex(int orderValue)
{
int i;
string id;
DataTable oDT = new DataTable();
oDT = dsOrder.Tables[0];
id = orderValue.ToString();
for(i=0; i<oDT.Rows.Count-1;i++)

if (id == oDT.Rows[i]["DisplayOrder"].ToString())

return i;
return 0;

}

I dont understand where am going wrong. Appreciate if someone can help me
figure it out

Thanks
Nov 22 '05 #1
0 827

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

Similar topics

0
by: Allan Allan Ebdrup | last post by:
Hi I'm looking for the best webinterface for editing database data, for example publishing a table with foreign keys shown as a dropdown. I don't care what database the interface is for (MSSQL,...
1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
9
by: thechaosengine | last post by:
Hi all, I have a problem that I havent really come accross before. I need to be able to allow the user to set a dropdown control to a particular colour value. The permissable values come from...
0
by: Deepa | last post by:
Hi, I'm having real trouble trying to figure out how to change the selectedIndex of a drop down list that sits in the Edit Template of a datagrid bound to a dataset. I get the DataValueField...
13
by: melih.onvural | last post by:
Group, I'm having a tough time understanding some of the previous posts on this topic so I wanted to write what I've tried and hope that you can help me troubleshoot. I have a dropdown populated...
0
by: G Dawg | last post by:
I am trying to set the default item in a dropdown list on the fly, I would like to be able to retrieve a value from a Database and set the value that I just retrieved as the default list item. ...
1
by: Demtri | last post by:
Hi, I need to create an ASP.Net form that will allow one to edit data in various tables. What I need is the following: When a user initially arrives to a form they are provided a drop down list...
0
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2...
5
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
4
by: genojoe | last post by:
My development computer (1 gig, XP Home Edition SP2) freezes when I am editing a very large VB.NET project. It can take minutes to move between a code pane and the Find and Replace pane. On...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...
0
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
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
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
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.