iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a problem with dropdown in webgrid. The grid shows sometimes the id instead text. All list entries are available. See sreen!
I use newest version of all libraries...webgrid is 7.0.7200.419
This is code snippet where I create dropdown DataTable:
private DataTable DataPartDienstleistungen { get { DataTable parts = new DataTable(); parts.Columns.AddRange(new DataColumn[]{ new DataColumn("DienstleistungID"), new DataColumn("Bezeichnung") }); Dienstleistungsart dienstleistungsart = DaoFactory.Instance.DienstleistungsartDao.Get(long.Parse(DienstleistungsartID.Value)); if (dienstleistungsart != null) { IList<Dienstleistung> list = dienstleistungsart.Dienstleistungen; foreach (Dienstleistung d in list) { if (d.Mengeneinheit != Mengeneinheit.Basket) { parts.Rows.Add(new object[] { d.ID, d.Bezeichnung }); } } } return parts; } } protected void Webgrid_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e) { WebGridTable basketTable = WebGrid1.GetTableByName("BasketdienstleistungCollection"); basketTable.AllowAddNew = AddNew.Yes; basketTable.AllowEdit = Edit.Yes; basketTable.AllowDelete = Delete.Yes; basketTable.AllowSorting = Sorting.Yes; WebValueList list = basketTable.Columns.GetNamedItem("PartDienstleistungID").ValueList; list.DataSource = DataPartDienstleistungen; list.DataTextField = "Bezeichnung"; list.DataValueField = "DienstleistungID"; }
This is code snippet of page:
<div style="height: 300px;"> <ISWebGrid:WebGrid ID="WebGrid1" runat="server" DefaultStyleMode="Silver" Height="210" AllowAutoDataCaching="false" UseDefaultStyle="True" Width="100%" OnInitializeRow="Webgrid_InitializeRow" DataMember="DienstleistungCollection" DataSourceID="ISDataSource1" OnInitializeLayout="Webgrid_InitializeLayout"> <LayoutSettings AllowAddNew="No" AllowColumnSizing="No" AllowDelete="No" AllowEdit="No" EditOnClick="true" StatusBarVisible="false" AllowSorting="Default" Hierarchical="True" TreeLines="false"> <TextSettings Language="UseCulture"> </TextSettings> </LayoutSettings> <RootTable Caption="DienstleistungCollection" DataKeyField="DienstleistungID" DataMember="DienstleistungCollection" RowHeaders="No" ColumnHeaders="No"> <ChildTables> <ISWebGrid:WebGridTable Caption="BasketdienstleistungCollection" DataKeyField="BasketdienstleistungID" DataMember="BasketdienstleistungCollection"> <Columns> <ISWebGrid:WebGridColumn Caption="BasketdienstleistungID" DataMember="BasketdienstleistungID" DataType="System.Int64" Name="BasketdienstleistungID" Visible="false" DefaultValue="0"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="DienstleistungID" DataMember="DienstleistungID" DataType="System.Int64" Name="DienstleistungID" Visible="false"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Anzahl" DataMember="Anzahl" DataType="System.Int32" Name="Anzahl" TextboxMaxlength="5"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Dienstleistung" DataMember="PartDienstleistungID" DataType="System.Int64" Name="PartDienstleistungID" EditType="DropdownList" Width="200" InputRequired="true"> </ISWebGrid:WebGridColumn> </Columns> </ISWebGrid:WebGridTable> </ChildTables> <Columns> <ISWebGrid:WebGridColumn Caption="DienstleistungID" DataMember="DienstleistungID" DataType="System.Int64" Name="DienstleistungID" Visible="false"> </ISWebGrid:WebGridColumn> <ISWebGrid:WebGridColumn Caption="Bezeichnung" DataMember="Bezeichnung" Name="Bezeichnung" Width="200"> </ISWebGrid:WebGridColumn> </Columns> </RootTable> </ISWebGrid:WebGrid>
I found the solution by myself.
If you use DataTable as Datasource then specify the type of column like this:
DataTable parts = new DataTable(); parts.Columns.AddRange(new DataColumn[]{ new DataColumn("DienstleistungID", typeof(long)), new DataColumn("Bezeichnung") });
Glad to hear the good news.
Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname