asp.net - Retrieve data from DataList -


This will be a simple table on the page, which has some initial cells and another user should enter. I use ItemTemplate with DataTemplate:

  & lt; ItemTemplate & gt; & Lt; ASP: text box id = "celltextbox" runat = "server" text = '& lt;% # bind ("cell")% & gt; / & Gt; & Lt; / ItemTemplate & gt;  

In the code, I override this control database ():

  public override zero databind () {MyDataList.DataSource = dataTable; MyDataList.DataBind (); }  

It does not work anymore. Users enter some cells and click the Submit button, but the data is not included (Data of this button in the method of handing onclick event) - only initial What should I do?

I'm not sure that I fully understand but I think that you have problems because you have a page There is a need to check a post on the load. You can try something like this:

  Public Zero Page_load (object sender, event case e) {if (! This.IsPostBack) { MyDataList.DataSource = myManager.GetDataTable (); MyDataList.DataBind (); }}  

In this way, the data will only be bound to control partial page load and not later requests. Page_ load will be called on each request, and this means code and buttons will be executed before your button click method in your page_load. So you need to see IsPostBack property on your page to see if the current request is a post back. If it is, do not bind your data under your control as you will lose the account entered by the user.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -