471,353 Members | 1,667 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

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
Jul 21 '05 #1
0 809

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Allan Allan Ebdrup | last post: by
9 posts views Thread by thechaosengine | last post: by
reply views Thread by G Dawg | last post: by
reply views Thread by Deepa | last post: by
5 posts views Thread by Gil | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.