By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,596 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

dropdownlist index in an editable datagrid

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.