471,310 Members | 1,346 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.

DropDown list not displaying--Urgent!!

Hi
Am doing a web app which has a datagrid with template columns. One of the
columns has dropdowns for each row. I also have the EditCommandColumn. The
problem am facing is I just see the last value of the dataset for the
dropdowns(in the non-edit mode). and moreover its just showing it as a label
instead of a dropdown. But once I click the Edit button, its displaying the
dropdowns with all dataset values. Here is the code for my ItemDataBound
event handler

protected void dgDetails_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.EditItem)
{
DropDownList list = (DropDownList)e.Item.FindControl("ddlOrder");
list.DataSource = dsOrder;
list.DataTextField = dsOrder.Tables[0].Columns[0].ColumnName;
list.DataValueField = dsOrder.Tables[0].Columns[0].ColumnName;
list.DataBind();
}
}

and this is the html
<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" DataTextField="DisplayOrder"
DataSource='<%# dsOrder %>' SelectedIndex='<%#
GetSelectedIndex(DataBinder.Eval(Container.DataIte m,"DisplayOrder").ToString()) %>'
AutoPostBack="True" >
</ASP:DROPDOWNLIST>
</EDITITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>

What do I have to do so that the dropdowns are shown when the page loads the
first time too.
Can anyone help me with it please?

Thanks
Jul 21 '05 #1
3 1204
JV
Take a look at "Customizing Column Layout in Display and Edit Mode" on
http://msdn.microsoft.com/library/de...vercontrol.asp

"Deepa" <De***@discussions.microsoft.com> wrote
Am doing a web app which has a datagrid with template columns. One of the
columns has dropdowns for each row. I also have the EditCommandColumn.

Jul 21 '05 #2
thanks JV... it was helpful. But I have another issue here. Am populating the
dropdowns right, and when I edit it,its going to update in the database,
which causes the updated values to be displayed for the dropdowns. But I want
a set of specific values (its 1 thru 5) to be displayed for them instead of
the updated set of values. Do you have any thoughts on how to do this?

thanks
"JV" wrote:
Take a look at "Customizing Column Layout in Display and Edit Mode" on
http://msdn.microsoft.com/library/de...vercontrol.asp

"Deepa" <De***@discussions.microsoft.com> wrote
Am doing a web app which has a datagrid with template columns. One of the
columns has dropdowns for each row. I also have the EditCommandColumn.


Jul 21 '05 #3
JV
Sorry, I don't understand your question.
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Paul | last post: by
5 posts views Thread by jung_h_park | last post: by
reply views Thread by Andrus | 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.