Click to See Complete Forum and Search --> : how to keep data in datalist after post
davidnav
May 13th, 2004, 07:36 AM
This is the situation:
I have a datalist which gets filled in by users. This list is based on a Dataset. The users must then add extra info in textboxes next to the values from the DS.
After posting the page, I do some checks. The checks are done by comparing the filled in values to other values from the DS. I have to fill my dataset again so I can compare. It compares correctly.
In case of bad input by the user, I show an error together with that same datalist.
However the fields that were filled in by the customer are blank again, so my question is: How to take care of it so the input by the user is still present on the page (is this the dataview?)
Tanx,
David
Sonu Kapoor
May 13th, 2004, 09:26 AM
Maybe you have to include your code in the postback method ? Like this:
if(!Page.IsPostBack){}
Maybe you can show us some code ? It is very difficult to help without seeing any code.
Sonu
davidnav
May 13th, 2004, 09:37 AM
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tTable As DataTable
Dim rRow As DataRow
If Request("actie") = 1 Then 'This is the postback check
Dim i As Integer = 1 'An Index for specifying the Insertion Point.
Dim kleur As Integer
Dim zwart As Integer
Dim FoutPrio1 As String
Dim EenIngevuld As Boolean
BindData(False)
EenIngevuld = False
'Loop through dataset/get values from datalist
For Each tTable In DS.Tables
For Each rRow In tTable.Rows
If IsNumeric(Request.Form("ZW" & rRow.Item(0))) Then
zwart = Request.Form("ZW" & rRow.Item(0))
Else
zwart = 0
End If
If IsNumeric(Request.Form("KL" & rRow.Item(0))) Then
kleur = Request.Form("KL" & rRow.Item(0))
Else
kleur = 0
End If
'///////////////////////CONTROLES//////////////////////'
If (zwart = 0) And (kleur = 0) Then
no action
Else
EenIngevuld = True
If (zwart >= rRow.Item(2)) And (kleur >= rRow.Item(3)) Then
'Update data:
Else
'Give error
FoutPrio1 = "De nieuwe tellerstanden dienen groter te zijn dan de oude."
End If
End If
'///////////////////CONTROLES EINDE////////////////////'
Next rRow
Next tTable
'Parse the eror
If EenIngevuld = False Then
LabelFoutmelding.Text = "Ongeldige input, reden: "
LabelFoutmelding.Text = LabelFoutmelding.Text & "<br>" & "Er moet minstens één tellerstand worden ingevuld."
Else
If FoutPrio1 <> "" Then
LabelFoutmelding.Text = FoutPrio1
Else
LabelFoutmelding.Text = ""
End If
End If
Else
BindData(True)
End If
_--------------------------------------------------------------------
This is the binddata method:
Public Function BindData(ByVal Tolist As Boolean)
sql = "select Nr_, Omschrijving, [Teller ZW laatste fact] as tellerzwlaatst, [Teller KL laatste fact] as tellerkllaatst, [Teller laatste fact dat] as tellerlaatstdat from [CRONUS BELGIË NV$Unit] where [Tellerstanden ingeven] = 1"
DS = New DataSet
MyAdapter = New SqlDataAdapter(sql, MyConnection)
MyAdapter.Fill(DS, "Unit")
If Tolist Then
datalistIngaveTellerstanden.DataSource = DS.Tables("Unit")
datalistIngaveTellerstanden.DataBind()
End If
End Function[CODE]
Sonu Kapoor
May 13th, 2004, 09:42 AM
Try to post the code in the postback method. Also take a look here (http://www.15seconds.com/issue/020102.htm). I am sure that the article will help you.
Sonu
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.