G
Guest
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>
<ASPROPDOWNLIST ID="ddlOrder" runat="server" CssClass="label242"
Height="20" Width="40" Font-Size="12px"
DataValueField="DisplayOrder" DataTextField="DisplayOrder"
DataSource='<%# dsOrder %>' SelectedIndex='<%#
GetSelectedIndex(DataBinder.Eval(Container.DataItem,"DisplayOrder").ToString()) %>'
AutoPostBack="True" >
</ASPROPDOWNLIST>
</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
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>
<ASPROPDOWNLIST ID="ddlOrder" runat="server" CssClass="label242"
Height="20" Width="40" Font-Size="12px"
DataValueField="DisplayOrder" DataTextField="DisplayOrder"
DataSource='<%# dsOrder %>' SelectedIndex='<%#
GetSelectedIndex(DataBinder.Eval(Container.DataItem,"DisplayOrder").ToString()) %>'
AutoPostBack="True" >
</ASPROPDOWNLIST>
</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