I'm retrieving a date value from sql and its returning the time portion as well as the date.
I just want to display the date in the drop down.
Is there something like a DataFormatString for the dropdown???
chuck
Hello,
one option could be to use ItemTemplate and Databinder.Eval, then put whatever you want.
for example:
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" DataKeyFields="OrderID" ValueField="OrderID" DataSourceID="AccessDataSource1"> <DropDownItemBinding KeyField="Orders" /> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "OrderDate", "{0:d}")%> </ItemTemplate> </ig:WebDropDown> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb" SelectCommand="SELECT [OrderID], [OrderDate] FROM [Orders]"></asp:AccessDataSource>
Also take a look at the online samples: WebDropDown Templates
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebDropDown_Templating.html
Hope this helps
That's 1/2 way there. The drop down items (only one at this time) have the date formatted properly.
Here's the code
<ig:WebDropDown ID="DateSelectionWebDropDown" runat="server" Width="200px" CssClass="Textboxes" DataSourceID="DateDropDownSqlDataSource" DataKeyFields="ImportDate" DropDownAnimationType="Bounce"> <AutoPostBackFlags SelectionChanged="On" /> <DropDownItemBinding TextField="ImportDate" ValueField="ImportDate" /> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "ImportDate", "{0:MM/dd/yyyy}")%> </ItemTemplate></ig:WebDropDown>
But when the program is run, the date displayed in the dropdown box has the full date/time components. When dropped down, the date is displayed correctly. strange??
any ideas.
Hi,
try with the following code:
<ig:WebDropDown ID="DateSelectionWebDropDown" runat="server" Width="200px" CssClass="Textboxes" DataSourceID="DateDropDownSqlDataSource" DataKeyFields="ImportDate" DropDownAnimationType="Bounce" ValueField="ImportDate"> <AutoPostBackFlags SelectionChanged="On" /> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "ImportDate", "{0:MM/dd/yyyy}")%> </ItemTemplate> </ig:WebDropDown>
and call DateSelectionWebDropDown.DataBind(); if the items are not shown in the dropdown after postback.
Try with this
<ig:WebDropDown ID="WebDropDown1" runat="server" Width="200px" CurrentValue=""
ValueField="OrderDate" DataSourceID="AccessDataSource1">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "OrderDate", "{0:MM/dd/yyyy}")%>
</ItemTemplate>
<AutoPostBackFlags ValueChanged="On" SelectionChanged="On" />
</ig:WebDropDown>
...
protected void Page_Load(object sender, EventArgs e)
{
int index = WebDropDown1.SelectedItemIndex;
WebDropDown1.DataBind();
WebDropDown1.SelectedItemIndex = index;
}
Could you highlight the differences between my question sample and your answer. It looks like I'm already doing exactly what you suggest, and its not working correctly. The first item show when the drop down is not shown has the date with the time portion, not formatted.
any other suggestions??