Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Page_loading with redirection

  Asked By: Techguy    Date: Jul 29    Category: Asp.net    Views: 742
  

in this webform i create dataSet, add tables, add rows to that table and blabla,...
Then i (by clicking on button) redirect to another page where i select an article and all data is written in a dataSet
Then i go back to my first webform where i want to see that data add in my datagrid.

This can simply been done by rebind the datagrid to the OrderTabel (where data is stored in)

But i don't know how to handle with that Page_Load or other command...

Which event do i have to use, so that if my page load on the very first time add tables of part 1
otherwise, when it is load again from redirection it binds my dataGrid (as in my part 2)...

Txs in advance, Scoopie

(i could be it has smth to do with rendering, but i didn't understood as well the published article about this)

CODE:


Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If Not IsPostBack Then 'PART 1

'Declareer een DataSet
Dim myDataSet As New DataSet()
'Declareer een DataTable OrderTabel die dan binnen die dataSet moet komen
Dim myDataTable As DataTable = New DataTable("OrderTabel")
'Voeg de kolommen van de DataTable in
myDataTable.Columns.Add("klantid", System.Type.GetType("System.String"))
myDataTable.Columns.Add("artikelid", System.Type.GetType("System.String"))
myDataTable.Columns.Add("anaam", System.Type.GetType("System.String"))
myDataTable.Columns.Add("prijs", System.Type.GetType("System.Double"))

myDataTable.Columns.Add("totaleprijs", System.Type.GetType("System.String"))
myDataTable.Columns.Add("datum", System.Type.GetType("System.DateTime"))
myDataTable.Columns.Add("aantal", System.Type.GetType("System.String"))
'Voeg de dataTable toe aan de dataSet
myDataSet.Tables.Add(myDataTable)
Dim objArray(6) As Object
'eerst blanco regel invoeren
objArray(0) = hiddenKlantID.Text
'klantid
objArray(1) = "-1"
'artikelid
objArray(2) = ""
'anaam
objArray(3) = "0"
'prijs
objArray(4) = "0"
'totale prijs
objArray(5) =
Date.Today() 'Datum
objArray(6) = ""
'Aantal
myDataTable.Rows.Add(objArray)
'Voeg een temporytable in in de DataSet die de gegevens bevat voor de dropdownlist
'Indien u dynamisch werkt kan u deze tabel telkens opnieuw wijzigen met de
'gewenste gegevens. Hier nemen we telkens hetzelfde aantal gegevens.
'*********************
Dim myDropDownTable As DataTable = New DataTable("DDLTabel")
'myDataSet.Tables.Add(myDropDownTable)
myDropDownTable.Columns.Add("aantal", System.Type.GetType("System.String"))
myDataSet.Tables.Add(myDropDownTable)

Dim objDataRow As DataRow
Dim x As Integer
For x = 1 To 10 Step 1
objDataRow = myDropDownTable.NewRow
objDataRow("aantal") = x
myDropDownTable.Rows.Add(objDataRow)
Next
'Stop eerst in sessie zodat de tabel zeker bestaat alvorens je gaat gaan
'verbinden!!!!!!!!!!!!!!!!!!!
Session("data") = myDataSet
'De datasource is de dataSet
DataGrid1.DataSource = myDataSet
'Het datamember is de desbetreffende tabel binnen die dataSet
DataGrid1.DataMember = "OrderTabel"
'verbind aan een datagrid
DataGrid1.DataBind()

Else 'PART 1

'voor het geval de pagina teruggegeven wordt uit de articlepage.aspx...
Dim myDataSet As DataSet = CType(Session("data"), DataSet)
Dim myDataTable As DataTable = myDataSet.Tables("OrderTabel")
DataGrid1.DataSource = myDataSet
DataGrid1.DataMember = "OrderTabel"
DataGrid1.DataBind()
End If

End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Page_loading with redirection Or get search suggestion and latest updates.