471,310 Members | 1,026 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

dropdownlist index inside a datagrid

I have an editable datagrid
one of itz column is a dropdownlist
<asp:TemplateColumn>
<ItemTemplate> <asp:Label ID=lblAreaWebsiteID Runat=server
text='<%#
DataBinder.Eval(Container.DataItem,"WebsiteName")% >'></asp:Label>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlWebsiteName_edit" Runat=server
DataSource="<%# PopulateWebsiteID()%>" DataTextField="name"
DataValueField="id"
OnPreRender=SetDropDownIndexForWebite></asp:DropDownList>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

I want to set the dropdownindex on the ddl to the seleced index in edit
mode.

what i do rite now is
public void SetDropDownIndexForWebite(object sender,System.EventArgs e)
{
DropDownList ed;
ed = (DropDownList)sender;
ed.SelectedIndex = ed.Items.IndexOf(ed.Items.FindByText(name));
}

protected void dgAreaList_Edit(object sender,DataGridCommandEventArgs
e)
{
dgAreaList.ShowFooter= false;
dgAreaList.EditItemIndex= e.Item.ItemIndex;
Label lblAreaWebsiteID =
(Label)e.Item.FindControl("lblAreaWebsiteID");
getAreaList();
name = lblAreaWebsiteID.Text;
}

but it doesnt work.

Jan 3 '06 #1
0 1002

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by tfsmag | last post: by
reply views Thread by rosydwin | 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.