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
Dear Sir/ Madam,
I added a dynamically generated webcombo inside a place holder, bind it to a datasource, when I try to input value into the webcombo, the page will reload twice (one is post back, another one is not postback (flypostback?) and I can't input any value to the webcombo (since the page is reload)
Please kindly help to investigate the issue. Thanks.
Regards,
Fung
here is the code:
aspx page:
<body runat="server" style="width: 100%; height: 100%; overflow:hidden"> <form id="form1" runat="server"> <div> <asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Enabled"> </asp:PlaceHolder> <br /> </div> </form> </body>
vb Code:
Public Class webCombo Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then PlaceHolder1.Controls.Add(createCBO) End If End Sub Private Function GetData2() As DataTable Dim dt As New DataTable With dt.Columns .Add("Text") .Add("Value") .Add("Display") End With For i As Integer = 1 To 250 With dt.Rows .Add(i & i, i, i) End With Next Return dt End Function Private Function createCBO() As ISNet.WebUI.WebCombo.WebCombo Dim cboWebCombo As New ISNet.WebUI.WebCombo.WebCombo Dim dt As New DataTable Dim sbBindText As New System.Text.StringBuilder dt = GetData2() With cboWebCombo .ID = "cbo" .DataValueField = dt.Columns(0).ColumnName .DataTextField = dt.Columns(1).ColumnName .DataSource = dt .DataBind() .UseDefaultStyle = True .Enabled = True .Latency = 250 .AllowAutoPostback = False End With Return cboWebCombo End Function End Class
Hello Fung,
I did not understand about "it won't be able to retieve data". Shouldn't when you type in WebCombo pr show the dropdown, it will trigger IntializeDataSource event?
Unfortunately, you could not place Not IsPostBack condition, because WebCombo must be always created. Otherwise, it's gone.
Regards,Handy
Hello,
Based On my investigation, this is not cause by PlaceHolder. Event a small div can also replicate your issue. Some of your approaches is not correct and not postback condition in Page_Load also cause this issue.
Please see my approaches in below. Hope this helps.
Imports System Imports System.Data Imports System.Configuration Imports System.Collections Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Imports ISNet.WebUI.WebCombo Public Class webCombo Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load PlaceHolder1.Controls.Add(createCBO) End Sub Private Function GetData2() As DataTable Dim dt As New DataTable With dt.Columns .Add("Text") .Add("Value") .Add("Display") End With For i As Integer = 1 To 250 With dt.Rows .Add(i & i, i, i) End With Next Return dt End Function Private Function createCBO() As WebCombo Dim cboWebCombo As New WebCombo Dim dt As New DataTable Dim sbBindText As New System.Text.StringBuilder AddHandler cboWebCombo.InitializeDataSource, AddressOf cboWebCombo_InitializeDataSource With cboWebCombo .ID = "cbo" .UseDefaultStyle = True .Enabled = True .Latency = 250 .AllowAutoPostback = False End With Return cboWebCombo End Function Protected Sub cboWebCombo_InitializeDataSource(ByVal sender As Object, ByVal e As ISNet.WebUI.WebCombo.DataSourceEventArgs) Dim cboWebCombo As WebCombo = CType(sender, WebCombo) e.DataSource = GetData2() cboWebCombo.DataValueField = "Text" cboWebCombo.DataTextField = "Value" End Sub End Class
Public Class webCombo Inherits System.Web.UI.Page
Thanks Handy for providing a better approach. I have tried the suggestion. But the problem still persist, please kindly help.
Thanks again,
Which one is not working? The fullpostback should be not persisted anymore. Please see my attached sample.
Thanks, your sample is working. Since I need to generate a lot of webcom in one page and it increase the page's loading time if I go through the whole page load each time flypostback.
to describe in code would be:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then PlaceHolder1.Controls.Add(createCBO) End If End Sub
but when I do this to the sample you provided, the webcombo would not be able to retreive data. Is there any work around for this case?
Thanks and Regards,
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