By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

Putting a string onto a stream to be read into a DataGrid

P: n/a
Hi,

Am I trying to hold the data of a DataGrid in a label so that when the form
is reposted the DataGrid can be repopulated. The problem I am having is that
I don't understand how to get the text into a stream in order to be able to
use DataSetOutcomes1.ReadXML(MyStream).

Thanks in advance,

James
Web Form:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="course_new.aspx.vb"
Inherits="_1137InsetBookingSystem.course_new"%>
<!-- #INCLUDE file="headeraspx.inc" -->
<!-- #INCLUDE file="tableheader.inc" -->
<form id="FormNewCourse" method="post" runat="server">
<table cellSpacing="0" cols="3" cellPadding="0" width="100%" border="0">
<tr>
<td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
Font-Bold="True">Course Title</asp:label></td>
<td><asp:textbox id="txtCourseTitle" runat="server"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
Font-Bold="True">Course Tutor(s)</asp:label></td>
</tr>
<tr>
<td vAlign="top">&nbsp;</td>
<td><asp:textbox id="txtCourseTutor" runat="server"></asp:textbox></td>
<td><asp:button id="cmdAdd" runat="server" Text="Add" BackColor="#F6CD7A"
BorderStyle="Solid" BorderWidth="1px"
Width="80px"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbox id="txtTutorList" runat="server" Rows="5"
TextMode="MultiLine"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblLearningOutcomes" runat="server"
Font-Bold="True">Learning Outcomes</asp:label></td>
</TD></tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td>
<td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
BackColor="#F6CD7A" BorderStyle="Solid"
BorderWidth="1px" Width="80px"
CausesValidation="False"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:datagrid id=DataGridOutcomes runat="server" GridLines="None"
AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
DatasetOutcomes1 %>">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<ul>
<li>
</li>
</ul>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Name" SortExpression="Name"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="DisplayOrder"
SortExpression="DisplayOrder" HeaderText="DisplayOrder"></asp:BoundColumn>
<asp:ButtonColumn Text="Delete"
ButtonType="PushButton"></asp:ButtonColumn>
<asp:ButtonColumn Text="Edit"
ButtonType="PushButton"></asp:ButtonColumn>
</Columns>
</asp:datagrid></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblOutcomes"
runat="server"></asp:label></td>
</tr>
</table>
</form>
<!-- #INCLUDE file="tablefooter.inc" -->
<!-- #INCLUDE file="footer.inc" -->
Code Bind:

Imports System
Imports System.IO
Imports System.Xml
Public Class course_new
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.DatasetOutcomes1 = New _1137InsetBookingSystem.DatasetOutcomes
CType(Me.DatasetOutcomes1,
System.ComponentModel.ISupportInitialize).BeginIni t()
'
'DatasetOutcomes1
'
Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
Me.DatasetOutcomes1.Locale = New
System.Globalization.CultureInfo("en-GB")
CType(Me.DatasetOutcomes1,
System.ComponentModel.ISupportInitialize).EndInit( )

End Sub
Protected WithEvents lblCourseTitle As System.Web.UI.WebControls.Label
Protected WithEvents txtCourseTitle As System.Web.UI.WebControls.TextBox
Protected WithEvents txtCourseTutor As System.Web.UI.WebControls.TextBox
Protected WithEvents txtTutorList As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
Protected WithEvents txtOutcome As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdAddOutcome As System.Web.UI.WebControls.Button
Protected WithEvents lblCourseTutorList As
System.Web.UI.WebControls.Label
Protected WithEvents lblLearningOutcomes As
System.Web.UI.WebControls.Label
Protected WithEvents DataGridOutcomes As
System.Web.UI.WebControls.DataGrid
Protected WithEvents DatasetOutcomes1 As
_1137InsetBookingSystem.DatasetOutcomes
Protected WithEvents lblOutcomes As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Public gstrTableTitle As String = "Create Course"
Public gstrTableAttribs As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.DataGridOutcomes.DataBind()
Else
Dim str As String = Me.lblOutcomes.Text
Dim MyStream As StreamReader

If str.Length > 0 Then
MyStream = New StreamReader(str)
Me.DatasetOutcomes1.ReadXml(MyStream)

End If

'Me.DatasetOutcomes1.GetXml()
'

End If
End Sub

Private Sub UpdateOutcomes()
Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
Me.DataGridOutcomes.DataBind()
End Sub

Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdAdd.Click

If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1 Then
If Me.txtTutorList.Text.Length > 0 Then
Me.txtTutorList.Text = Me.txtTutorList.Text & ";" & vbCrLf &
Me.txtCourseTutor.Text
Else
Me.txtTutorList.Text = Me.txtCourseTutor.Text
End If
End If
End Sub

Private Sub cmdAddOutcome_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdAddOutcome.Click
Dim dr As DatasetOutcomes.OutcomesRow

dr = Me.DatasetOutcomes1.Outcomes.NewRow()
dr.Item("Name") = Me.txtOutcome.Text
dr.Item("DisplayOrder") = Me.DatasetOutcomes1.Outcomes.Rows.Count
'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
Me.DatasetOutcomes1.Outcomes.Rows.Count)

DatasetOutcomes1.Outcomes.Rows.Add(dr)
Me.DataGridOutcomes.DataBind()

Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml

End Sub

End Class

Nov 17 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
Most of the time, your code can follow this pattern:

Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeHow()
myDataGrid.DataSource = myDataSet
myDataGrid.DataMember = "FirstTable"

DataBind()
End If
End Sub

When the page is posted back, the grid (or other controls) will populate
itself from ViewState.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Hi,

Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the text into a stream in order to be able to use DataSetOutcomes1.ReadXML(MyStream).

Thanks in advance,

James
Web Form:

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="course_new.aspx.vb"
Inherits="_1137InsetBookingSystem.course_new"%>
<!-- #INCLUDE file="headeraspx.inc" -->
<!-- #INCLUDE file="tableheader.inc" -->
<form id="FormNewCourse" method="post" runat="server">
<table cellSpacing="0" cols="3" cellPadding="0" width="100%" border="0">
<tr>
<td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
Font-Bold="True">Course Title</asp:label></td>
<td><asp:textbox id="txtCourseTitle" runat="server"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
Font-Bold="True">Course Tutor(s)</asp:label></td>
</tr>
<tr>
<td vAlign="top">&nbsp;</td>
<td><asp:textbox id="txtCourseTutor" runat="server"></asp:textbox></td>
<td><asp:button id="cmdAdd" runat="server" Text="Add" BackColor="#F6CD7A" BorderStyle="Solid" BorderWidth="1px"
Width="80px"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbox id="txtTutorList" runat="server" Rows="5"
TextMode="MultiLine"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblLearningOutcomes" runat="server"
Font-Bold="True">Learning Outcomes</asp:label></td>
</TD></tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td>
<td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
BackColor="#F6CD7A" BorderStyle="Solid"
BorderWidth="1px" Width="80px"
CausesValidation="False"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:datagrid id=DataGridOutcomes runat="server" GridLines="None"
AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
DatasetOutcomes1 %>">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<ul>
<li>
</li>
</ul>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Name" SortExpression="Name"
HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="DisplayOrder"
SortExpression="DisplayOrder" HeaderText="DisplayOrder"></asp:BoundColumn>
<asp:ButtonColumn Text="Delete"
ButtonType="PushButton"></asp:ButtonColumn>
<asp:ButtonColumn Text="Edit"
ButtonType="PushButton"></asp:ButtonColumn>
</Columns>
</asp:datagrid></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><asp:label id="lblOutcomes"
runat="server"></asp:label></td>
</tr>
</table>
</form>
<!-- #INCLUDE file="tablefooter.inc" -->
<!-- #INCLUDE file="footer.inc" -->
Code Bind:

Imports System
Imports System.IO
Imports System.Xml
Public Class course_new
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.DatasetOutcomes1 = New _1137InsetBookingSystem.DatasetOutcomes
CType(Me.DatasetOutcomes1,
System.ComponentModel.ISupportInitialize).BeginIni t()
'
'DatasetOutcomes1
'
Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
Me.DatasetOutcomes1.Locale = New
System.Globalization.CultureInfo("en-GB")
CType(Me.DatasetOutcomes1,
System.ComponentModel.ISupportInitialize).EndInit( )

End Sub
Protected WithEvents lblCourseTitle As System.Web.UI.WebControls.Label
Protected WithEvents txtCourseTitle As System.Web.UI.WebControls.TextBox Protected WithEvents txtCourseTutor As System.Web.UI.WebControls.TextBox Protected WithEvents txtTutorList As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
Protected WithEvents txtOutcome As System.Web.UI.WebControls.TextBox
Protected WithEvents cmdAddOutcome As System.Web.UI.WebControls.Button
Protected WithEvents lblCourseTutorList As
System.Web.UI.WebControls.Label
Protected WithEvents lblLearningOutcomes As
System.Web.UI.WebControls.Label
Protected WithEvents DataGridOutcomes As
System.Web.UI.WebControls.DataGrid
Protected WithEvents DatasetOutcomes1 As
_1137InsetBookingSystem.DatasetOutcomes
Protected WithEvents lblOutcomes As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Public gstrTableTitle As String = "Create Course"
Public gstrTableAttribs As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Me.DataGridOutcomes.DataBind()
Else
Dim str As String = Me.lblOutcomes.Text
Dim MyStream As StreamReader

If str.Length > 0 Then
MyStream = New StreamReader(str)
Me.DatasetOutcomes1.ReadXml(MyStream)

End If

'Me.DatasetOutcomes1.GetXml()
'

End If
End Sub

Private Sub UpdateOutcomes()
Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
Me.DataGridOutcomes.DataBind()
End Sub

Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdAdd.Click

If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1 Then
If Me.txtTutorList.Text.Length > 0 Then
Me.txtTutorList.Text = Me.txtTutorList.Text & ";" & vbCrLf & Me.txtCourseTutor.Text
Else
Me.txtTutorList.Text = Me.txtCourseTutor.Text
End If
End If
End Sub

Private Sub cmdAddOutcome_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles cmdAddOutcome.Click
Dim dr As DatasetOutcomes.OutcomesRow

dr = Me.DatasetOutcomes1.Outcomes.NewRow()
dr.Item("Name") = Me.txtOutcome.Text
dr.Item("DisplayOrder") = Me.DatasetOutcomes1.Outcomes.Rows.Count
'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
Me.DatasetOutcomes1.Outcomes.Rows.Count)

DatasetOutcomes1.Outcomes.Rows.Add(dr)
Me.DataGridOutcomes.DataBind()

Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml

End Sub

End Class

Nov 17 '05 #2

P: n/a
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the
need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Managed to solve it using:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Me.DataGridOutcomes.DataBind()
Else
'Create the XML fragment to be parsed.
Dim xmlFrag As String = Me.lblOutcomes.Text

If xmlFrag.Length > 0 Then

'Create the XmlNamespaceManager.
Dim nt As NameTable = New NameTable
Dim nsmgr As XmlNamespaceManager = New
XmlNamespaceManager(nt)

'Create the XmlParserContext.
Dim context As XmlParserContext = New
XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag,
XmlNodeType.Element, context)

Me.DatasetCourse.ReadXml(xmlTR)

End If
End If
End Sub
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Most of the time, your code can follow this pattern:

Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeHow()
myDataGrid.DataSource = myDataSet
myDataGrid.DataMember = "FirstTable"

DataBind()
End If
End Sub

When the page is posted back, the grid (or other controls) will populate itself from ViewState.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> Hi,
>
> Am I trying to hold the data of a DataGrid in a label so that when the form
> is reposted the DataGrid can be repopulated. The problem I am having is that
> I don't understand how to get the text into a stream in order to be able to
> use DataSetOutcomes1.ReadXML(MyStream).
>
> Thanks in advance,
>
> James
>
>
> Web Form:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="course_new.aspx.vb"
> Inherits="_1137InsetBookingSystem.course_new"%>
> <!-- #INCLUDE file="headeraspx.inc" -->
> <!-- #INCLUDE file="tableheader.inc" -->
> <form id="FormNewCourse" method="post" runat="server">
> <table cellSpacing="0" cols="3" cellPadding="0" width="100%"

border="0">
> <tr>
> <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
> Font-Bold="True">Course Title</asp:label></td>
> <td><asp:textbox id="txtCourseTitle"

runat="server"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
> Font-Bold="True">Course Tutor(s)</asp:label></td>
> </tr>
> <tr>
> <td vAlign="top">&nbsp;</td>
> <td><asp:textbox id="txtCourseTutor"

runat="server"></asp:textbox></td>
> <td><asp:button id="cmdAdd" runat="server" Text="Add"
BackColor="#F6CD7A"
> BorderStyle="Solid" BorderWidth="1px"
> Width="80px"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> TextMode="MultiLine"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblLearningOutcomes" runat="server" > Font-Bold="True">Learning Outcomes</asp:label></td>
> </TD></tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td> > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> BackColor="#F6CD7A" BorderStyle="Solid"
> BorderWidth="1px" Width="80px"
> CausesValidation="False"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:datagrid id=DataGridOutcomes runat="server" GridLines="None" > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
> DatasetOutcomes1 %>">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <ul>
> <li>
> </li>
> </ul>
> </ItemTemplate>
> </asp:TemplateColumn>
> <asp:BoundColumn DataField="Name" SortExpression="Name"
> HeaderText="Name"></asp:BoundColumn>
> <asp:BoundColumn DataField="DisplayOrder"
> SortExpression="DisplayOrder"

HeaderText="DisplayOrder"></asp:BoundColumn>
> <asp:ButtonColumn Text="Delete"
> ButtonType="PushButton"></asp:ButtonColumn>
> <asp:ButtonColumn Text="Edit"
> ButtonType="PushButton"></asp:ButtonColumn>
> </Columns>
> </asp:datagrid></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblOutcomes"
> runat="server"></asp:label></td>
> </tr>
> </table>
> </form>
> <!-- #INCLUDE file="tablefooter.inc" -->
> <!-- #INCLUDE file="footer.inc" -->
>
>
> Code Bind:
>
> Imports System
> Imports System.IO
> Imports System.Xml
>
>
> Public Class course_new
> Inherits System.Web.UI.Page
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.DatasetOutcomes1 = New

_1137InsetBookingSystem.DatasetOutcomes
> CType(Me.DatasetOutcomes1,
> System.ComponentModel.ISupportInitialize).BeginIni t()
> '
> 'DatasetOutcomes1
> '
> Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> Me.DatasetOutcomes1.Locale = New
> System.Globalization.CultureInfo("en-GB")
> CType(Me.DatasetOutcomes1,
> System.ComponentModel.ISupportInitialize).EndInit( )
>
> End Sub
> Protected WithEvents lblCourseTitle As

System.Web.UI.WebControls.Label
> Protected WithEvents txtCourseTitle As
System.Web.UI.WebControls.TextBox
> Protected WithEvents txtCourseTutor As
System.Web.UI.WebControls.TextBox
> Protected WithEvents txtTutorList As

System.Web.UI.WebControls.TextBox
> Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
> Protected WithEvents txtOutcome As System.Web.UI.WebControls.TextBox > Protected WithEvents cmdAddOutcome As

System.Web.UI.WebControls.Button
> Protected WithEvents lblCourseTutorList As
> System.Web.UI.WebControls.Label
> Protected WithEvents lblLearningOutcomes As
> System.Web.UI.WebControls.Label
> Protected WithEvents DataGridOutcomes As
> System.Web.UI.WebControls.DataGrid
> Protected WithEvents DatasetOutcomes1 As
> _1137InsetBookingSystem.DatasetOutcomes
> Protected WithEvents lblOutcomes As System.Web.UI.WebControls.Label >
> 'NOTE: The following placeholder declaration is required by the Web Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceholderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer > 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
>
> #End Region
> Public gstrTableTitle As String = "Create Course"
> Public gstrTableAttribs As String
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
> Me.DataGridOutcomes.DataBind()
> Else
> Dim str As String = Me.lblOutcomes.Text
> Dim MyStream As StreamReader
>
> If str.Length > 0 Then
> MyStream = New StreamReader(str)
> Me.DatasetOutcomes1.ReadXml(MyStream)
>
> End If
>
>
>
> 'Me.DatasetOutcomes1.GetXml()
> '
>
> End If
> End Sub
>
> Private Sub UpdateOutcomes()
> Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> Me.DataGridOutcomes.DataBind()
> End Sub
>
> Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles cmdAdd.Click
>
> If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1 Then > If Me.txtTutorList.Text.Length > 0 Then
> Me.txtTutorList.Text = Me.txtTutorList.Text & ";" &

vbCrLf
&
> Me.txtCourseTutor.Text
> Else
> Me.txtTutorList.Text = Me.txtCourseTutor.Text
> End If
> End If
> End Sub
>
> Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,

ByVal
e
> As System.EventArgs) Handles cmdAddOutcome.Click
> Dim dr As DatasetOutcomes.OutcomesRow
>
> dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> dr.Item("Name") = Me.txtOutcome.Text
> dr.Item("DisplayOrder") =

Me.DatasetOutcomes1.Outcomes.Rows.Count
> 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> Me.DatasetOutcomes1.Outcomes.Rows.Count)
>
> DatasetOutcomes1.Outcomes.Rows.Add(dr)
> Me.DataGridOutcomes.DataBind()
>
> Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
>
> End Sub
>
> End Class
>
>
>



Nov 17 '05 #3

P: n/a
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see
that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually answered?
:-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per
session, I think I'd keep it in Session, but flush to disk whenever a change
was made. That way, if the session expires (seen as Session("DatasetCourse")
Is Nothing), then you can re-load it from the disk file (which you'll need
to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the
need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Managed to solve it using:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Me.DataGridOutcomes.DataBind()
Else
'Create the XML fragment to be parsed.
Dim xmlFrag As String = Me.lblOutcomes.Text

If xmlFrag.Length > 0 Then

'Create the XmlNamespaceManager.
Dim nt As NameTable = New NameTable
Dim nsmgr As XmlNamespaceManager = New
XmlNamespaceManager(nt)

'Create the XmlParserContext.
Dim context As XmlParserContext = New
XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag, XmlNodeType.Element, context)

Me.DatasetCourse.ReadXml(xmlTR)

End If
End If
End Sub
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
> Most of the time, your code can follow this pattern:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> System.EventArgs) Handles MyBase.Load
> If Not Page.IsPostBack Then
> myDataSet = GetDataSetSomeHow()
> myDataGrid.DataSource = myDataSet
> myDataGrid.DataMember = "FirstTable"
>
> DataBind()
> End If
> End Sub
>
> When the page is posted back, the grid (or other controls) will populate > itself from ViewState.
> --
> John Saunders
> Internet Engineer
> jo***********@surfcontrol.com
>
>
> "James Norton-Jones" <ja****************@stopford.com> wrote in message > news:3f***********************@news.easynet.co.uk. ..
> > Hi,
> >
> > Am I trying to hold the data of a DataGrid in a label so that when the > form
> > is reposted the DataGrid can be repopulated. The problem I am having
is
> that
> > I don't understand how to get the text into a stream in order to
be
able
> to
> > use DataSetOutcomes1.ReadXML(MyStream).
> >
> > Thanks in advance,
> >
> > James
> >
> >
> > Web Form:
> >
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Codebehind="course_new.aspx.vb"
> > Inherits="_1137InsetBookingSystem.course_new"%>
> > <!-- #INCLUDE file="headeraspx.inc" -->
> > <!-- #INCLUDE file="tableheader.inc" -->
> > <form id="FormNewCourse" method="post" runat="server">
> > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
border="0">
> > <tr>
> > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
> > Font-Bold="True">Course Title</asp:label></td>
> > <td><asp:textbox id="txtCourseTitle"
runat="server"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblCourseTutorList"
runat="server" > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > </tr>
> > <tr>
> > <td vAlign="top">&nbsp;</td>
> > <td><asp:textbox id="txtCourseTutor"
runat="server"></asp:textbox></td>
> > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> BackColor="#F6CD7A"
> > BorderStyle="Solid" BorderWidth="1px"
> > Width="80px"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > TextMode="MultiLine"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblLearningOutcomes"
runat="server" > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > </TD></tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td> > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> > BackColor="#F6CD7A" BorderStyle="Solid"
> > BorderWidth="1px" Width="80px"
> > CausesValidation="False"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:datagrid id=DataGridOutcomes runat="server"

GridLines="None"
> > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
> > DatasetOutcomes1 %>">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > <Columns>
> > <asp:TemplateColumn>
> > <ItemTemplate>
> > <ul>
> > <li>
> > </li>
> > </ul>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > HeaderText="Name"></asp:BoundColumn>
> > <asp:BoundColumn DataField="DisplayOrder"
> > SortExpression="DisplayOrder"
HeaderText="DisplayOrder"></asp:BoundColumn>
> > <asp:ButtonColumn Text="Delete"
> > ButtonType="PushButton"></asp:ButtonColumn>
> > <asp:ButtonColumn Text="Edit"
> > ButtonType="PushButton"></asp:ButtonColumn>
> > </Columns>
> > </asp:datagrid></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblOutcomes"
> > runat="server"></asp:label></td>
> > </tr>
> > </table>
> > </form>
> > <!-- #INCLUDE file="tablefooter.inc" -->
> > <!-- #INCLUDE file="footer.inc" -->
> >
> >
> > Code Bind:
> >
> > Imports System
> > Imports System.IO
> > Imports System.Xml
> >
> >
> > Public Class course_new
> > Inherits System.Web.UI.Page
> >
> > #Region " Web Form Designer Generated Code "
> >
> > 'This call is required by the Web Form Designer.
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> > Me.DatasetOutcomes1 = New
_1137InsetBookingSystem.DatasetOutcomes
> > CType(Me.DatasetOutcomes1,
> > System.ComponentModel.ISupportInitialize).BeginIni t()
> > '
> > 'DatasetOutcomes1
> > '
> > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > Me.DatasetOutcomes1.Locale = New
> > System.Globalization.CultureInfo("en-GB")
> > CType(Me.DatasetOutcomes1,
> > System.ComponentModel.ISupportInitialize).EndInit( )
> >
> > End Sub
> > Protected WithEvents lblCourseTitle As
System.Web.UI.WebControls.Label
> > Protected WithEvents txtCourseTitle As
> System.Web.UI.WebControls.TextBox
> > Protected WithEvents txtCourseTutor As
> System.Web.UI.WebControls.TextBox
> > Protected WithEvents txtTutorList As
System.Web.UI.WebControls.TextBox
> > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button > > Protected WithEvents txtOutcome As

System.Web.UI.WebControls.TextBox
> > Protected WithEvents cmdAddOutcome As
System.Web.UI.WebControls.Button
> > Protected WithEvents lblCourseTutorList As
> > System.Web.UI.WebControls.Label
> > Protected WithEvents lblLearningOutcomes As
> > System.Web.UI.WebControls.Label
> > Protected WithEvents DataGridOutcomes As
> > System.Web.UI.WebControls.DataGrid
> > Protected WithEvents DatasetOutcomes1 As
> > _1137InsetBookingSystem.DatasetOutcomes
> > Protected WithEvents lblOutcomes As

System.Web.UI.WebControls.Label
> >
> > 'NOTE: The following placeholder declaration is required by the Web
> Form
> > Designer.
> > 'Do not delete or move it.
> > Private designerPlaceholderDeclaration As System.Object
> >
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As > > System.EventArgs) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form

Designer
> > 'Do not modify it using the code editor.
> > InitializeComponent()
> > End Sub
> >
> > #End Region
> > Public gstrTableTitle As String = "Create Course"
> > Public gstrTableAttribs As String
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> > Me.DataGridOutcomes.DataBind()
> > Else
> > Dim str As String = Me.lblOutcomes.Text
> > Dim MyStream As StreamReader
> >
> > If str.Length > 0 Then
> > MyStream = New StreamReader(str)
> > Me.DatasetOutcomes1.ReadXml(MyStream)
> >
> > End If
> >
> >
> >
> > 'Me.DatasetOutcomes1.GetXml()
> > '
> >
> > End If
> > End Sub
> >
> > Private Sub UpdateOutcomes()
> > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > Me.DataGridOutcomes.DataBind()
> > End Sub
> >
> > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles cmdAdd.Click
> >
> > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1

Then
> > If Me.txtTutorList.Text.Length > 0 Then
> > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"

& vbCrLf
> &
> > Me.txtCourseTutor.Text
> > Else
> > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > End If
> > End If
> > End Sub
> >
> > Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,

ByVal
e
> > As System.EventArgs) Handles cmdAddOutcome.Click
> > Dim dr As DatasetOutcomes.OutcomesRow
> >
> > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > dr.Item("Name") = Me.txtOutcome.Text
> > dr.Item("DisplayOrder") =
Me.DatasetOutcomes1.Outcomes.Rows.Count
> > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> >
> > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > Me.DataGridOutcomes.DataBind()
> >
> > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> >
> > End Sub
> >
> > End Class
> >
> >
> >
>
>



Nov 17 '05 #4

P: n/a
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually answered? :-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per
session, I think I'd keep it in Session, but flush to disk whenever a change was made. That way, if the session expires (seen as Session("DatasetCourse") Is Nothing), then you can re-load it from the disk file (which you'll need
to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> Managed to solve it using:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
>
> Me.DataGridOutcomes.DataBind()
> Else
> 'Create the XML fragment to be parsed.
> Dim xmlFrag As String = Me.lblOutcomes.Text
>
> If xmlFrag.Length > 0 Then
>
> 'Create the XmlNamespaceManager.
> Dim nt As NameTable = New NameTable
> Dim nsmgr As XmlNamespaceManager = New
> XmlNamespaceManager(nt)
>
> 'Create the XmlParserContext.
> Dim context As XmlParserContext = New
> XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
>
> 'Create the reader.
> Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag, > XmlNodeType.Element, context)
>
> Me.DatasetCourse.ReadXml(xmlTR)
>
> End If
> End If
> End Sub
>
>
> "John Saunders" <jo***********@surfcontrol.com> wrote in message
> news:OP**************@TK2MSFTNGP09.phx.gbl...
> > Most of the time, your code can follow this pattern:
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> > System.EventArgs) Handles MyBase.Load
> > If Not Page.IsPostBack Then
> > myDataSet = GetDataSetSomeHow()
> > myDataGrid.DataSource = myDataSet
> > myDataGrid.DataMember = "FirstTable"
> >
> > DataBind()
> > End If
> > End Sub
> >
> > When the page is posted back, the grid (or other controls) will populate
> > itself from ViewState.
> > --
> > John Saunders
> > Internet Engineer
> > jo***********@surfcontrol.com
> >
> >
> > "James Norton-Jones" <ja****************@stopford.com> wrote in

message
> > news:3f***********************@news.easynet.co.uk. ..
> > > Hi,
> > >
> > > Am I trying to hold the data of a DataGrid in a label so that when the
> > form
> > > is reposted the DataGrid can be repopulated. The problem I am having is
> > that
> > > I don't understand how to get the text into a stream in order to be able
> > to
> > > use DataSetOutcomes1.ReadXML(MyStream).
> > >
> > > Thanks in advance,
> > >
> > > James
> > >
> > >
> > > Web Form:
> > >
> > > <%@ Page Language="vb" AutoEventWireup="false"
> > > Codebehind="course_new.aspx.vb"
> > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > <!-- #INCLUDE file="tableheader.inc" -->
> > > <form id="FormNewCourse" method="post" runat="server">
> > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> border="0">
> > > <tr>
> > > <td vAlign="top"><asp:label id="lblCourseTitle"
runat="server" > > > Font-Bold="True">Course Title</asp:label></td>
> > > <td><asp:textbox id="txtCourseTitle"
> runat="server"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblCourseTutorList"

runat="server" > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > </tr>
> > > <tr>
> > > <td vAlign="top">&nbsp;</td>
> > > <td><asp:textbox id="txtCourseTutor"
> runat="server"></asp:textbox></td>
> > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > BackColor="#F6CD7A"
> > > BorderStyle="Solid" BorderWidth="1px"
> > > Width="80px"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > > TextMode="MultiLine"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblLearningOutcomes"

runat="server"
> > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > </TD></tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbox id="txtOutcome"

runat="server"></asp:textbox></td>
> > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > BorderWidth="1px" Width="80px"
> > > CausesValidation="False"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:datagrid id=DataGridOutcomes runat="server"
GridLines="None"
> > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%# > > > DatasetOutcomes1 %>">
> > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > <Columns>
> > > <asp:TemplateColumn>
> > > <ItemTemplate>
> > > <ul>
> > > <li>
> > > </li>
> > > </ul>
> > > </ItemTemplate>
> > > </asp:TemplateColumn>
> > > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > > HeaderText="Name"></asp:BoundColumn>
> > > <asp:BoundColumn DataField="DisplayOrder"
> > > SortExpression="DisplayOrder"
> HeaderText="DisplayOrder"></asp:BoundColumn>
> > > <asp:ButtonColumn Text="Delete"
> > > ButtonType="PushButton"></asp:ButtonColumn>
> > > <asp:ButtonColumn Text="Edit"
> > > ButtonType="PushButton"></asp:ButtonColumn>
> > > </Columns>
> > > </asp:datagrid></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > runat="server"></asp:label></td>
> > > </tr>
> > > </table>
> > > </form>
> > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > <!-- #INCLUDE file="footer.inc" -->
> > >
> > >
> > > Code Bind:
> > >
> > > Imports System
> > > Imports System.IO
> > > Imports System.Xml
> > >
> > >
> > > Public Class course_new
> > > Inherits System.Web.UI.Page
> > >
> > > #Region " Web Form Designer Generated Code "
> > >
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > InitializeComponent()
> > > Me.DatasetOutcomes1 = New
> _1137InsetBookingSystem.DatasetOutcomes
> > > CType(Me.DatasetOutcomes1,
> > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > '
> > > 'DatasetOutcomes1
> > > '
> > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > > Me.DatasetOutcomes1.Locale = New
> > > System.Globalization.CultureInfo("en-GB")
> > > CType(Me.DatasetOutcomes1,
> > > System.ComponentModel.ISupportInitialize).EndInit( )
> > >
> > > End Sub
> > > Protected WithEvents lblCourseTitle As
> System.Web.UI.WebControls.Label
> > > Protected WithEvents txtCourseTitle As
> > System.Web.UI.WebControls.TextBox
> > > Protected WithEvents txtCourseTutor As
> > System.Web.UI.WebControls.TextBox
> > > Protected WithEvents txtTutorList As
> System.Web.UI.WebControls.TextBox
> > > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button > > > Protected WithEvents txtOutcome As
System.Web.UI.WebControls.TextBox
> > > Protected WithEvents cmdAddOutcome As
> System.Web.UI.WebControls.Button
> > > Protected WithEvents lblCourseTutorList As
> > > System.Web.UI.WebControls.Label
> > > Protected WithEvents lblLearningOutcomes As
> > > System.Web.UI.WebControls.Label
> > > Protected WithEvents DataGridOutcomes As
> > > System.Web.UI.WebControls.DataGrid
> > > Protected WithEvents DatasetOutcomes1 As
> > > _1137InsetBookingSystem.DatasetOutcomes
> > > Protected WithEvents lblOutcomes As
System.Web.UI.WebControls.Label
> > >
> > > 'NOTE: The following placeholder declaration is required by the Web
> > Form
> > > Designer.
> > > 'Do not delete or move it.
> > > Private designerPlaceholderDeclaration As System.Object
> > >
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > >
> > > #End Region
> > > Public gstrTableTitle As String = "Create Course"
> > > Public gstrTableAttribs As String
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > If Not Page.IsPostBack Then
> > > Me.DataGridOutcomes.DataBind()
> > > Else
> > > Dim str As String = Me.lblOutcomes.Text
> > > Dim MyStream As StreamReader
> > >
> > > If str.Length > 0 Then
> > > MyStream = New StreamReader(str)
> > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > >
> > > End If
> > >
> > >
> > >
> > > 'Me.DatasetOutcomes1.GetXml()
> > > '
> > >
> > > End If
> > > End Sub
> > >
> > > Private Sub UpdateOutcomes()
> > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > > Me.DataGridOutcomes.DataBind()
> > > End Sub
> > >
> > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e
As
> > > System.EventArgs) Handles cmdAdd.Click
> > >
> > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) <
1 Then
> > > If Me.txtTutorList.Text.Length > 0 Then
> > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"
& > vbCrLf
> > &
> > > Me.txtCourseTutor.Text
> > > Else
> > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > > End If
> > > End If
> > > End Sub
> > >
> > > Private Sub cmdAddOutcome_Click(ByVal sender As

System.Object, ByVal
> e
> > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > Dim dr As DatasetOutcomes.OutcomesRow
> > >
> > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > dr.Item("Name") = Me.txtOutcome.Text
> > > dr.Item("DisplayOrder") =
> Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > >
> > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > Me.DataGridOutcomes.DataBind()
> > >
> > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #5

P: n/a
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the
need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Managed to solve it using:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Me.DataGridOutcomes.DataBind()
Else
'Create the XML fragment to be parsed.
Dim xmlFrag As String = Me.lblOutcomes.Text

If xmlFrag.Length > 0 Then

'Create the XmlNamespaceManager.
Dim nt As NameTable = New NameTable
Dim nsmgr As XmlNamespaceManager = New
XmlNamespaceManager(nt)

'Create the XmlParserContext.
Dim context As XmlParserContext = New
XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag,
XmlNodeType.Element, context)

Me.DatasetCourse.ReadXml(xmlTR)

End If
End If
End Sub
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Most of the time, your code can follow this pattern:

Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeHow()
myDataGrid.DataSource = myDataSet
myDataGrid.DataMember = "FirstTable"

DataBind()
End If
End Sub

When the page is posted back, the grid (or other controls) will populate itself from ViewState.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> Hi,
>
> Am I trying to hold the data of a DataGrid in a label so that when the form
> is reposted the DataGrid can be repopulated. The problem I am having is that
> I don't understand how to get the text into a stream in order to be able to
> use DataSetOutcomes1.ReadXML(MyStream).
>
> Thanks in advance,
>
> James
>
>
> Web Form:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="course_new.aspx.vb"
> Inherits="_1137InsetBookingSystem.course_new"%>
> <!-- #INCLUDE file="headeraspx.inc" -->
> <!-- #INCLUDE file="tableheader.inc" -->
> <form id="FormNewCourse" method="post" runat="server">
> <table cellSpacing="0" cols="3" cellPadding="0" width="100%"

border="0">
> <tr>
> <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
> Font-Bold="True">Course Title</asp:label></td>
> <td><asp:textbox id="txtCourseTitle"

runat="server"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
> Font-Bold="True">Course Tutor(s)</asp:label></td>
> </tr>
> <tr>
> <td vAlign="top">&nbsp;</td>
> <td><asp:textbox id="txtCourseTutor"

runat="server"></asp:textbox></td>
> <td><asp:button id="cmdAdd" runat="server" Text="Add"
BackColor="#F6CD7A"
> BorderStyle="Solid" BorderWidth="1px"
> Width="80px"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> TextMode="MultiLine"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblLearningOutcomes" runat="server" > Font-Bold="True">Learning Outcomes</asp:label></td>
> </TD></tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td> > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> BackColor="#F6CD7A" BorderStyle="Solid"
> BorderWidth="1px" Width="80px"
> CausesValidation="False"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:datagrid id=DataGridOutcomes runat="server" GridLines="None" > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
> DatasetOutcomes1 %>">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> <Columns>
> <asp:TemplateColumn>
> <ItemTemplate>
> <ul>
> <li>
> </li>
> </ul>
> </ItemTemplate>
> </asp:TemplateColumn>
> <asp:BoundColumn DataField="Name" SortExpression="Name"
> HeaderText="Name"></asp:BoundColumn>
> <asp:BoundColumn DataField="DisplayOrder"
> SortExpression="DisplayOrder"

HeaderText="DisplayOrder"></asp:BoundColumn>
> <asp:ButtonColumn Text="Delete"
> ButtonType="PushButton"></asp:ButtonColumn>
> <asp:ButtonColumn Text="Edit"
> ButtonType="PushButton"></asp:ButtonColumn>
> </Columns>
> </asp:datagrid></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><asp:label id="lblOutcomes"
> runat="server"></asp:label></td>
> </tr>
> </table>
> </form>
> <!-- #INCLUDE file="tablefooter.inc" -->
> <!-- #INCLUDE file="footer.inc" -->
>
>
> Code Bind:
>
> Imports System
> Imports System.IO
> Imports System.Xml
>
>
> Public Class course_new
> Inherits System.Web.UI.Page
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.DatasetOutcomes1 = New

_1137InsetBookingSystem.DatasetOutcomes
> CType(Me.DatasetOutcomes1,
> System.ComponentModel.ISupportInitialize).BeginIni t()
> '
> 'DatasetOutcomes1
> '
> Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> Me.DatasetOutcomes1.Locale = New
> System.Globalization.CultureInfo("en-GB")
> CType(Me.DatasetOutcomes1,
> System.ComponentModel.ISupportInitialize).EndInit( )
>
> End Sub
> Protected WithEvents lblCourseTitle As

System.Web.UI.WebControls.Label
> Protected WithEvents txtCourseTitle As
System.Web.UI.WebControls.TextBox
> Protected WithEvents txtCourseTutor As
System.Web.UI.WebControls.TextBox
> Protected WithEvents txtTutorList As

System.Web.UI.WebControls.TextBox
> Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
> Protected WithEvents txtOutcome As System.Web.UI.WebControls.TextBox > Protected WithEvents cmdAddOutcome As

System.Web.UI.WebControls.Button
> Protected WithEvents lblCourseTutorList As
> System.Web.UI.WebControls.Label
> Protected WithEvents lblLearningOutcomes As
> System.Web.UI.WebControls.Label
> Protected WithEvents DataGridOutcomes As
> System.Web.UI.WebControls.DataGrid
> Protected WithEvents DatasetOutcomes1 As
> _1137InsetBookingSystem.DatasetOutcomes
> Protected WithEvents lblOutcomes As System.Web.UI.WebControls.Label >
> 'NOTE: The following placeholder declaration is required by the Web Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceholderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer > 'Do not modify it using the code editor.
> InitializeComponent()
> End Sub
>
> #End Region
> Public gstrTableTitle As String = "Create Course"
> Public gstrTableAttribs As String
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
> Me.DataGridOutcomes.DataBind()
> Else
> Dim str As String = Me.lblOutcomes.Text
> Dim MyStream As StreamReader
>
> If str.Length > 0 Then
> MyStream = New StreamReader(str)
> Me.DatasetOutcomes1.ReadXml(MyStream)
>
> End If
>
>
>
> 'Me.DatasetOutcomes1.GetXml()
> '
>
> End If
> End Sub
>
> Private Sub UpdateOutcomes()
> Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> Me.DataGridOutcomes.DataBind()
> End Sub
>
> Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles cmdAdd.Click
>
> If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1 Then > If Me.txtTutorList.Text.Length > 0 Then
> Me.txtTutorList.Text = Me.txtTutorList.Text & ";" &

vbCrLf
&
> Me.txtCourseTutor.Text
> Else
> Me.txtTutorList.Text = Me.txtCourseTutor.Text
> End If
> End If
> End Sub
>
> Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,

ByVal
e
> As System.EventArgs) Handles cmdAddOutcome.Click
> Dim dr As DatasetOutcomes.OutcomesRow
>
> dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> dr.Item("Name") = Me.txtOutcome.Text
> dr.Item("DisplayOrder") =

Me.DatasetOutcomes1.Outcomes.Rows.Count
> 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> Me.DatasetOutcomes1.Outcomes.Rows.Count)
>
> DatasetOutcomes1.Outcomes.Rows.Add(dr)
> Me.DataGridOutcomes.DataBind()
>
> Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
>
> End Sub
>
> End Class
>
>
>



Nov 17 '05 #6

P: n/a
Runs on multiple servers - and no Sql Server database to store session state
in.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see
that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually

answered?
:-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per session, I think I'd keep it in Session, but flush to disk whenever a

change
was made. That way, if the session expires (seen as

Session("DatasetCourse")
Is Nothing), then you can re-load it from the disk file (which you'll need to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and the data its self is an xml doc. There is no database behind it, hence the need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" /> <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
> James,
>
> I'm glad you solved your problem, but I'm wondering how you use
> DatasetCourse on postbacks?
> --
> John Saunders
> Internet Engineer
> jo***********@surfcontrol.com
>
> "James Norton-Jones" <ja****************@stopford.com> wrote in message > news:3f***********************@news.easynet.co.uk. ..
> > Managed to solve it using:
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> >
> > Me.DataGridOutcomes.DataBind()
> > Else
> > 'Create the XML fragment to be parsed.
> > Dim xmlFrag As String = Me.lblOutcomes.Text
> >
> > If xmlFrag.Length > 0 Then
> >
> > 'Create the XmlNamespaceManager.
> > Dim nt As NameTable = New NameTable
> > Dim nsmgr As XmlNamespaceManager = New
> > XmlNamespaceManager(nt)
> >
> > 'Create the XmlParserContext.
> > Dim context As XmlParserContext = New
> > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
> >
> > 'Create the reader.
> > Dim xmlTR As XmlTextReader = New

XmlTextReader(xmlFrag,
> > XmlNodeType.Element, context)
> >
> > Me.DatasetCourse.ReadXml(xmlTR)
> >
> > End If
> > End If
> > End Sub
> >
> >
> > "John Saunders" <jo***********@surfcontrol.com> wrote in message
> > news:OP**************@TK2MSFTNGP09.phx.gbl...
> > > Most of the time, your code can follow this pattern:
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> > > System.EventArgs) Handles MyBase.Load
> > > If Not Page.IsPostBack Then
> > > myDataSet = GetDataSetSomeHow()
> > > myDataGrid.DataSource = myDataSet
> > > myDataGrid.DataMember = "FirstTable"
> > >
> > > DataBind()
> > > End If
> > > End Sub
> > >
> > > When the page is posted back, the grid (or other controls) will
populate
> > > itself from ViewState.
> > > --
> > > John Saunders
> > > Internet Engineer
> > > jo***********@surfcontrol.com
> > >
> > >
> > > "James Norton-Jones" <ja****************@stopford.com> wrote in
message
> > > news:3f***********************@news.easynet.co.uk. ..
> > > > Hi,
> > > >
> > > > Am I trying to hold the data of a DataGrid in a label so that when the
> > > form
> > > > is reposted the DataGrid can be repopulated. The problem I am

having
> is
> > > that
> > > > I don't understand how to get the text into a stream in order to be
> able
> > > to
> > > > use DataSetOutcomes1.ReadXML(MyStream).
> > > >
> > > > Thanks in advance,
> > > >
> > > > James
> > > >
> > > >
> > > > Web Form:
> > > >
> > > > <%@ Page Language="vb" AutoEventWireup="false"
> > > > Codebehind="course_new.aspx.vb"
> > > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > > <!-- #INCLUDE file="tableheader.inc" -->
> > > > <form id="FormNewCourse" method="post" runat="server">
> > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> > border="0">
> > > > <tr>
> > > > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server" > > > > Font-Bold="True">Course Title</asp:label></td>
> > > > <td><asp:textbox id="txtCourseTitle"
> > runat="server"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblCourseTutorList"

runat="server"
> > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > > </tr>
> > > > <tr>
> > > > <td vAlign="top">&nbsp;</td>
> > > > <td><asp:textbox id="txtCourseTutor"
> > runat="server"></asp:textbox></td>
> > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > > BackColor="#F6CD7A"
> > > > BorderStyle="Solid" BorderWidth="1px"
> > > > Width="80px"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > > > TextMode="MultiLine"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
runat="server"
> > > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > > </TD></tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbox id="txtOutcome"
runat="server"></asp:textbox></td>
> > > > <td><asp:button id="cmdAddOutcome" runat="server"
Text="Add" > > > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > > BorderWidth="1px" Width="80px"
> > > > CausesValidation="False"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
> GridLines="None"
> > > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%# > > > > DatasetOutcomes1 %>">
> > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > <Columns>
> > > > <asp:TemplateColumn>
> > > > <ItemTemplate>
> > > > <ul>
> > > > <li>
> > > > </li>
> > > > </ul>
> > > > </ItemTemplate>
> > > > </asp:TemplateColumn>
> > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > > > HeaderText="Name"></asp:BoundColumn>
> > > > <asp:BoundColumn DataField="DisplayOrder"
> > > > SortExpression="DisplayOrder"
> > HeaderText="DisplayOrder"></asp:BoundColumn>
> > > > <asp:ButtonColumn Text="Delete"
> > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > <asp:ButtonColumn Text="Edit"
> > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > </Columns>
> > > > </asp:datagrid></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > > runat="server"></asp:label></td>
> > > > </tr>
> > > > </table>
> > > > </form>
> > > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > > <!-- #INCLUDE file="footer.inc" -->
> > > >
> > > >
> > > > Code Bind:
> > > >
> > > > Imports System
> > > > Imports System.IO
> > > > Imports System.Xml
> > > >
> > > >
> > > > Public Class course_new
> > > > Inherits System.Web.UI.Page
> > > >
> > > > #Region " Web Form Designer Generated Code "
> > > >
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > > InitializeComponent()
> > > > Me.DatasetOutcomes1 = New
> > _1137InsetBookingSystem.DatasetOutcomes
> > > > CType(Me.DatasetOutcomes1,
> > > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > > '
> > > > 'DatasetOutcomes1
> > > > '
> > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > > > Me.DatasetOutcomes1.Locale = New
> > > > System.Globalization.CultureInfo("en-GB")
> > > > CType(Me.DatasetOutcomes1,
> > > > System.ComponentModel.ISupportInitialize).EndInit( )
> > > >
> > > > End Sub
> > > > Protected WithEvents lblCourseTitle As
> > System.Web.UI.WebControls.Label
> > > > Protected WithEvents txtCourseTitle As
> > > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents txtCourseTutor As
> > > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents txtTutorList As
> > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents cmdAdd As

System.Web.UI.WebControls.Button
> > > > Protected WithEvents txtOutcome As
> System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents cmdAddOutcome As
> > System.Web.UI.WebControls.Button
> > > > Protected WithEvents lblCourseTutorList As
> > > > System.Web.UI.WebControls.Label
> > > > Protected WithEvents lblLearningOutcomes As
> > > > System.Web.UI.WebControls.Label
> > > > Protected WithEvents DataGridOutcomes As
> > > > System.Web.UI.WebControls.DataGrid
> > > > Protected WithEvents DatasetOutcomes1 As
> > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > Protected WithEvents lblOutcomes As
> System.Web.UI.WebControls.Label
> > > >
> > > > 'NOTE: The following placeholder declaration is required
by the
> Web
> > > Form
> > > > Designer.
> > > > 'Do not delete or move it.
> > > > Private designerPlaceholderDeclaration As System.Object
> > > >
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArgs) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeComponent()
> > > > End Sub
> > > >
> > > > #End Region
> > > > Public gstrTableTitle As String = "Create Course"
> > > > Public gstrTableAttribs As String
> > > >
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArgs) Handles MyBase.Load
> > > > 'Put user code to initialize the page here
> > > > If Not Page.IsPostBack Then
> > > > Me.DataGridOutcomes.DataBind()
> > > > Else
> > > > Dim str As String = Me.lblOutcomes.Text
> > > > Dim MyStream As StreamReader
> > > >
> > > > If str.Length > 0 Then
> > > > MyStream = New StreamReader(str)
> > > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > 'Me.DatasetOutcomes1.GetXml()
> > > > '
> > > >
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub UpdateOutcomes()
> > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > > > Me.DataGridOutcomes.DataBind()
> > > > End Sub
> > > >
> > > > Private Sub cmdAdd_Click(ByVal sender As System.Object,

ByVal
e
As
> > > > System.EventArgs) Handles cmdAdd.Click
> > > >
> > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text)

< 1 > Then
> > > > If Me.txtTutorList.Text.Length > 0 Then
> > > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"
&
> > vbCrLf
> > > &
> > > > Me.txtCourseTutor.Text
> > > > Else
> > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > > > End If
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub cmdAddOutcome_Click(ByVal sender As

System.Object, > ByVal
> > e
> > > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > > Dim dr As DatasetOutcomes.OutcomesRow
> > > >
> > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > > dr.Item("Name") = Me.txtOutcome.Text
> > > > dr.Item("DisplayOrder") =
> > Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > > >
> > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > > Me.DataGridOutcomes.DataBind()
> > > >
> > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > > >
> > > > End Sub
> > > >
> > > > End Class
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #7

P: n/a
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see
that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually answered?
:-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per
session, I think I'd keep it in Session, but flush to disk whenever a change
was made. That way, if the session expires (seen as Session("DatasetCourse")
Is Nothing), then you can re-load it from the disk file (which you'll need
to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the
need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Managed to solve it using:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then

Me.DataGridOutcomes.DataBind()
Else
'Create the XML fragment to be parsed.
Dim xmlFrag As String = Me.lblOutcomes.Text

If xmlFrag.Length > 0 Then

'Create the XmlNamespaceManager.
Dim nt As NameTable = New NameTable
Dim nsmgr As XmlNamespaceManager = New
XmlNamespaceManager(nt)

'Create the XmlParserContext.
Dim context As XmlParserContext = New
XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag, XmlNodeType.Element, context)

Me.DatasetCourse.ReadXml(xmlTR)

End If
End If
End Sub
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
> Most of the time, your code can follow this pattern:
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> System.EventArgs) Handles MyBase.Load
> If Not Page.IsPostBack Then
> myDataSet = GetDataSetSomeHow()
> myDataGrid.DataSource = myDataSet
> myDataGrid.DataMember = "FirstTable"
>
> DataBind()
> End If
> End Sub
>
> When the page is posted back, the grid (or other controls) will populate > itself from ViewState.
> --
> John Saunders
> Internet Engineer
> jo***********@surfcontrol.com
>
>
> "James Norton-Jones" <ja****************@stopford.com> wrote in message > news:3f***********************@news.easynet.co.uk. ..
> > Hi,
> >
> > Am I trying to hold the data of a DataGrid in a label so that when the > form
> > is reposted the DataGrid can be repopulated. The problem I am having
is
> that
> > I don't understand how to get the text into a stream in order to
be
able
> to
> > use DataSetOutcomes1.ReadXML(MyStream).
> >
> > Thanks in advance,
> >
> > James
> >
> >
> > Web Form:
> >
> > <%@ Page Language="vb" AutoEventWireup="false"
> > Codebehind="course_new.aspx.vb"
> > Inherits="_1137InsetBookingSystem.course_new"%>
> > <!-- #INCLUDE file="headeraspx.inc" -->
> > <!-- #INCLUDE file="tableheader.inc" -->
> > <form id="FormNewCourse" method="post" runat="server">
> > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
border="0">
> > <tr>
> > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
> > Font-Bold="True">Course Title</asp:label></td>
> > <td><asp:textbox id="txtCourseTitle"
runat="server"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblCourseTutorList"
runat="server" > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > </tr>
> > <tr>
> > <td vAlign="top">&nbsp;</td>
> > <td><asp:textbox id="txtCourseTutor"
runat="server"></asp:textbox></td>
> > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> BackColor="#F6CD7A"
> > BorderStyle="Solid" BorderWidth="1px"
> > Width="80px"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > TextMode="MultiLine"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblLearningOutcomes"
runat="server" > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > </TD></tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td> > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> > BackColor="#F6CD7A" BorderStyle="Solid"
> > BorderWidth="1px" Width="80px"
> > CausesValidation="False"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:datagrid id=DataGridOutcomes runat="server"

GridLines="None"
> > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
> > DatasetOutcomes1 %>">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > <Columns>
> > <asp:TemplateColumn>
> > <ItemTemplate>
> > <ul>
> > <li>
> > </li>
> > </ul>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > HeaderText="Name"></asp:BoundColumn>
> > <asp:BoundColumn DataField="DisplayOrder"
> > SortExpression="DisplayOrder"
HeaderText="DisplayOrder"></asp:BoundColumn>
> > <asp:ButtonColumn Text="Delete"
> > ButtonType="PushButton"></asp:ButtonColumn>
> > <asp:ButtonColumn Text="Edit"
> > ButtonType="PushButton"></asp:ButtonColumn>
> > </Columns>
> > </asp:datagrid></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><asp:label id="lblOutcomes"
> > runat="server"></asp:label></td>
> > </tr>
> > </table>
> > </form>
> > <!-- #INCLUDE file="tablefooter.inc" -->
> > <!-- #INCLUDE file="footer.inc" -->
> >
> >
> > Code Bind:
> >
> > Imports System
> > Imports System.IO
> > Imports System.Xml
> >
> >
> > Public Class course_new
> > Inherits System.Web.UI.Page
> >
> > #Region " Web Form Designer Generated Code "
> >
> > 'This call is required by the Web Form Designer.
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> > Me.DatasetOutcomes1 = New
_1137InsetBookingSystem.DatasetOutcomes
> > CType(Me.DatasetOutcomes1,
> > System.ComponentModel.ISupportInitialize).BeginIni t()
> > '
> > 'DatasetOutcomes1
> > '
> > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > Me.DatasetOutcomes1.Locale = New
> > System.Globalization.CultureInfo("en-GB")
> > CType(Me.DatasetOutcomes1,
> > System.ComponentModel.ISupportInitialize).EndInit( )
> >
> > End Sub
> > Protected WithEvents lblCourseTitle As
System.Web.UI.WebControls.Label
> > Protected WithEvents txtCourseTitle As
> System.Web.UI.WebControls.TextBox
> > Protected WithEvents txtCourseTutor As
> System.Web.UI.WebControls.TextBox
> > Protected WithEvents txtTutorList As
System.Web.UI.WebControls.TextBox
> > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button > > Protected WithEvents txtOutcome As

System.Web.UI.WebControls.TextBox
> > Protected WithEvents cmdAddOutcome As
System.Web.UI.WebControls.Button
> > Protected WithEvents lblCourseTutorList As
> > System.Web.UI.WebControls.Label
> > Protected WithEvents lblLearningOutcomes As
> > System.Web.UI.WebControls.Label
> > Protected WithEvents DataGridOutcomes As
> > System.Web.UI.WebControls.DataGrid
> > Protected WithEvents DatasetOutcomes1 As
> > _1137InsetBookingSystem.DatasetOutcomes
> > Protected WithEvents lblOutcomes As

System.Web.UI.WebControls.Label
> >
> > 'NOTE: The following placeholder declaration is required by the Web
> Form
> > Designer.
> > 'Do not delete or move it.
> > Private designerPlaceholderDeclaration As System.Object
> >
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As > > System.EventArgs) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form

Designer
> > 'Do not modify it using the code editor.
> > InitializeComponent()
> > End Sub
> >
> > #End Region
> > Public gstrTableTitle As String = "Create Course"
> > Public gstrTableAttribs As String
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> > Me.DataGridOutcomes.DataBind()
> > Else
> > Dim str As String = Me.lblOutcomes.Text
> > Dim MyStream As StreamReader
> >
> > If str.Length > 0 Then
> > MyStream = New StreamReader(str)
> > Me.DatasetOutcomes1.ReadXml(MyStream)
> >
> > End If
> >
> >
> >
> > 'Me.DatasetOutcomes1.GetXml()
> > '
> >
> > End If
> > End Sub
> >
> > Private Sub UpdateOutcomes()
> > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > Me.DataGridOutcomes.DataBind()
> > End Sub
> >
> > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles cmdAdd.Click
> >
> > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1

Then
> > If Me.txtTutorList.Text.Length > 0 Then
> > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"

& vbCrLf
> &
> > Me.txtCourseTutor.Text
> > Else
> > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > End If
> > End If
> > End Sub
> >
> > Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,

ByVal
e
> > As System.EventArgs) Handles cmdAddOutcome.Click
> > Dim dr As DatasetOutcomes.OutcomesRow
> >
> > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > dr.Item("Name") = Me.txtOutcome.Text
> > dr.Item("DisplayOrder") =
Me.DatasetOutcomes1.Outcomes.Rows.Count
> > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> >
> > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > Me.DataGridOutcomes.DataBind()
> >
> > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> >
> > End Sub
> >
> > End Class
> >
> >
> >
>
>



Nov 17 '05 #8

P: n/a
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually answered? :-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per
session, I think I'd keep it in Session, but flush to disk whenever a change was made. That way, if the session expires (seen as Session("DatasetCourse") Is Nothing), then you can re-load it from the disk file (which you'll need
to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and
the data its self is an xml doc. There is no database behind it, hence the need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" />
<xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
James,

I'm glad you solved your problem, but I'm wondering how you use
DatasetCourse on postbacks?
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> Managed to solve it using:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
>
> Me.DataGridOutcomes.DataBind()
> Else
> 'Create the XML fragment to be parsed.
> Dim xmlFrag As String = Me.lblOutcomes.Text
>
> If xmlFrag.Length > 0 Then
>
> 'Create the XmlNamespaceManager.
> Dim nt As NameTable = New NameTable
> Dim nsmgr As XmlNamespaceManager = New
> XmlNamespaceManager(nt)
>
> 'Create the XmlParserContext.
> Dim context As XmlParserContext = New
> XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
>
> 'Create the reader.
> Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag, > XmlNodeType.Element, context)
>
> Me.DatasetCourse.ReadXml(xmlTR)
>
> End If
> End If
> End Sub
>
>
> "John Saunders" <jo***********@surfcontrol.com> wrote in message
> news:OP**************@TK2MSFTNGP09.phx.gbl...
> > Most of the time, your code can follow this pattern:
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> > System.EventArgs) Handles MyBase.Load
> > If Not Page.IsPostBack Then
> > myDataSet = GetDataSetSomeHow()
> > myDataGrid.DataSource = myDataSet
> > myDataGrid.DataMember = "FirstTable"
> >
> > DataBind()
> > End If
> > End Sub
> >
> > When the page is posted back, the grid (or other controls) will populate
> > itself from ViewState.
> > --
> > John Saunders
> > Internet Engineer
> > jo***********@surfcontrol.com
> >
> >
> > "James Norton-Jones" <ja****************@stopford.com> wrote in

message
> > news:3f***********************@news.easynet.co.uk. ..
> > > Hi,
> > >
> > > Am I trying to hold the data of a DataGrid in a label so that when the
> > form
> > > is reposted the DataGrid can be repopulated. The problem I am having is
> > that
> > > I don't understand how to get the text into a stream in order to be able
> > to
> > > use DataSetOutcomes1.ReadXML(MyStream).
> > >
> > > Thanks in advance,
> > >
> > > James
> > >
> > >
> > > Web Form:
> > >
> > > <%@ Page Language="vb" AutoEventWireup="false"
> > > Codebehind="course_new.aspx.vb"
> > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > <!-- #INCLUDE file="tableheader.inc" -->
> > > <form id="FormNewCourse" method="post" runat="server">
> > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> border="0">
> > > <tr>
> > > <td vAlign="top"><asp:label id="lblCourseTitle"
runat="server" > > > Font-Bold="True">Course Title</asp:label></td>
> > > <td><asp:textbox id="txtCourseTitle"
> runat="server"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblCourseTutorList"

runat="server" > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > </tr>
> > > <tr>
> > > <td vAlign="top">&nbsp;</td>
> > > <td><asp:textbox id="txtCourseTutor"
> runat="server"></asp:textbox></td>
> > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > BackColor="#F6CD7A"
> > > BorderStyle="Solid" BorderWidth="1px"
> > > Width="80px"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > > TextMode="MultiLine"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblLearningOutcomes"

runat="server"
> > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > </TD></tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbox id="txtOutcome"

runat="server"></asp:textbox></td>
> > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
> > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > BorderWidth="1px" Width="80px"
> > > CausesValidation="False"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:datagrid id=DataGridOutcomes runat="server"
GridLines="None"
> > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%# > > > DatasetOutcomes1 %>">
> > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > <Columns>
> > > <asp:TemplateColumn>
> > > <ItemTemplate>
> > > <ul>
> > > <li>
> > > </li>
> > > </ul>
> > > </ItemTemplate>
> > > </asp:TemplateColumn>
> > > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > > HeaderText="Name"></asp:BoundColumn>
> > > <asp:BoundColumn DataField="DisplayOrder"
> > > SortExpression="DisplayOrder"
> HeaderText="DisplayOrder"></asp:BoundColumn>
> > > <asp:ButtonColumn Text="Delete"
> > > ButtonType="PushButton"></asp:ButtonColumn>
> > > <asp:ButtonColumn Text="Edit"
> > > ButtonType="PushButton"></asp:ButtonColumn>
> > > </Columns>
> > > </asp:datagrid></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > runat="server"></asp:label></td>
> > > </tr>
> > > </table>
> > > </form>
> > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > <!-- #INCLUDE file="footer.inc" -->
> > >
> > >
> > > Code Bind:
> > >
> > > Imports System
> > > Imports System.IO
> > > Imports System.Xml
> > >
> > >
> > > Public Class course_new
> > > Inherits System.Web.UI.Page
> > >
> > > #Region " Web Form Designer Generated Code "
> > >
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > InitializeComponent()
> > > Me.DatasetOutcomes1 = New
> _1137InsetBookingSystem.DatasetOutcomes
> > > CType(Me.DatasetOutcomes1,
> > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > '
> > > 'DatasetOutcomes1
> > > '
> > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > > Me.DatasetOutcomes1.Locale = New
> > > System.Globalization.CultureInfo("en-GB")
> > > CType(Me.DatasetOutcomes1,
> > > System.ComponentModel.ISupportInitialize).EndInit( )
> > >
> > > End Sub
> > > Protected WithEvents lblCourseTitle As
> System.Web.UI.WebControls.Label
> > > Protected WithEvents txtCourseTitle As
> > System.Web.UI.WebControls.TextBox
> > > Protected WithEvents txtCourseTutor As
> > System.Web.UI.WebControls.TextBox
> > > Protected WithEvents txtTutorList As
> System.Web.UI.WebControls.TextBox
> > > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button > > > Protected WithEvents txtOutcome As
System.Web.UI.WebControls.TextBox
> > > Protected WithEvents cmdAddOutcome As
> System.Web.UI.WebControls.Button
> > > Protected WithEvents lblCourseTutorList As
> > > System.Web.UI.WebControls.Label
> > > Protected WithEvents lblLearningOutcomes As
> > > System.Web.UI.WebControls.Label
> > > Protected WithEvents DataGridOutcomes As
> > > System.Web.UI.WebControls.DataGrid
> > > Protected WithEvents DatasetOutcomes1 As
> > > _1137InsetBookingSystem.DatasetOutcomes
> > > Protected WithEvents lblOutcomes As
System.Web.UI.WebControls.Label
> > >
> > > 'NOTE: The following placeholder declaration is required by the Web
> > Form
> > > Designer.
> > > 'Do not delete or move it.
> > > Private designerPlaceholderDeclaration As System.Object
> > >
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
Designer
> > > 'Do not modify it using the code editor.
> > > InitializeComponent()
> > > End Sub
> > >
> > > #End Region
> > > Public gstrTableTitle As String = "Create Course"
> > > Public gstrTableAttribs As String
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > If Not Page.IsPostBack Then
> > > Me.DataGridOutcomes.DataBind()
> > > Else
> > > Dim str As String = Me.lblOutcomes.Text
> > > Dim MyStream As StreamReader
> > >
> > > If str.Length > 0 Then
> > > MyStream = New StreamReader(str)
> > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > >
> > > End If
> > >
> > >
> > >
> > > 'Me.DatasetOutcomes1.GetXml()
> > > '
> > >
> > > End If
> > > End Sub
> > >
> > > Private Sub UpdateOutcomes()
> > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > > Me.DataGridOutcomes.DataBind()
> > > End Sub
> > >
> > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e
As
> > > System.EventArgs) Handles cmdAdd.Click
> > >
> > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) <
1 Then
> > > If Me.txtTutorList.Text.Length > 0 Then
> > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"
& > vbCrLf
> > &
> > > Me.txtCourseTutor.Text
> > > Else
> > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > > End If
> > > End If
> > > End Sub
> > >
> > > Private Sub cmdAddOutcome_Click(ByVal sender As

System.Object, ByVal
> e
> > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > Dim dr As DatasetOutcomes.OutcomesRow
> > >
> > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > dr.Item("Name") = Me.txtOutcome.Text
> > > dr.Item("DisplayOrder") =
> Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > >
> > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > Me.DataGridOutcomes.DataBind()
> > >
> > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #9

P: n/a
Runs on multiple servers - and no Sql Server database to store session state
in.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Ok, I don't think I've ever used an updateable XML file yet, so I didn't see
that. In order to update even a single row, you have to read in the entire
file.

Please pardon me for being dense, was your question ever actually

answered?
:-)

If I were you, I think I'd store DatasetCourse in Session state. On the
other hand, if you're going to be making multiple changes to the data per session, I think I'd keep it in Session, but flush to disk whenever a

change
was made. That way, if the session expires (seen as

Session("DatasetCourse")
Is Nothing), then you can re-load it from the disk file (which you'll need to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
DatasetCourse is linked to an xml schema to define the data structure and the data its self is an xml doc. There is no database behind it, hence the need to repopulate from the xml data on postback.
Schema:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="DatasetOutcomes"
targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
elementFormDefault="qualified"
attributeFormDefault="qualified"
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Outcomes">
<xs:complexType>
<xs:sequence>
<xs:element name="Description" type="xs:string" minOccurs="0" /> <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:Description" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:u1**************@TK2MSFTNGP09.phx.gbl...
> James,
>
> I'm glad you solved your problem, but I'm wondering how you use
> DatasetCourse on postbacks?
> --
> John Saunders
> Internet Engineer
> jo***********@surfcontrol.com
>
> "James Norton-Jones" <ja****************@stopford.com> wrote in message > news:3f***********************@news.easynet.co.uk. ..
> > Managed to solve it using:
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArgs) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> >
> > Me.DataGridOutcomes.DataBind()
> > Else
> > 'Create the XML fragment to be parsed.
> > Dim xmlFrag As String = Me.lblOutcomes.Text
> >
> > If xmlFrag.Length > 0 Then
> >
> > 'Create the XmlNamespaceManager.
> > Dim nt As NameTable = New NameTable
> > Dim nsmgr As XmlNamespaceManager = New
> > XmlNamespaceManager(nt)
> >
> > 'Create the XmlParserContext.
> > Dim context As XmlParserContext = New
> > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
> >
> > 'Create the reader.
> > Dim xmlTR As XmlTextReader = New

XmlTextReader(xmlFrag,
> > XmlNodeType.Element, context)
> >
> > Me.DatasetCourse.ReadXml(xmlTR)
> >
> > End If
> > End If
> > End Sub
> >
> >
> > "John Saunders" <jo***********@surfcontrol.com> wrote in message
> > news:OP**************@TK2MSFTNGP09.phx.gbl...
> > > Most of the time, your code can follow this pattern:
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
> > > System.EventArgs) Handles MyBase.Load
> > > If Not Page.IsPostBack Then
> > > myDataSet = GetDataSetSomeHow()
> > > myDataGrid.DataSource = myDataSet
> > > myDataGrid.DataMember = "FirstTable"
> > >
> > > DataBind()
> > > End If
> > > End Sub
> > >
> > > When the page is posted back, the grid (or other controls) will
populate
> > > itself from ViewState.
> > > --
> > > John Saunders
> > > Internet Engineer
> > > jo***********@surfcontrol.com
> > >
> > >
> > > "James Norton-Jones" <ja****************@stopford.com> wrote in
message
> > > news:3f***********************@news.easynet.co.uk. ..
> > > > Hi,
> > > >
> > > > Am I trying to hold the data of a DataGrid in a label so that when the
> > > form
> > > > is reposted the DataGrid can be repopulated. The problem I am

having
> is
> > > that
> > > > I don't understand how to get the text into a stream in order to be
> able
> > > to
> > > > use DataSetOutcomes1.ReadXML(MyStream).
> > > >
> > > > Thanks in advance,
> > > >
> > > > James
> > > >
> > > >
> > > > Web Form:
> > > >
> > > > <%@ Page Language="vb" AutoEventWireup="false"
> > > > Codebehind="course_new.aspx.vb"
> > > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > > <!-- #INCLUDE file="tableheader.inc" -->
> > > > <form id="FormNewCourse" method="post" runat="server">
> > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> > border="0">
> > > > <tr>
> > > > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server" > > > > Font-Bold="True">Course Title</asp:label></td>
> > > > <td><asp:textbox id="txtCourseTitle"
> > runat="server"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblCourseTutorList"

runat="server"
> > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > > </tr>
> > > > <tr>
> > > > <td vAlign="top">&nbsp;</td>
> > > > <td><asp:textbox id="txtCourseTutor"
> > runat="server"></asp:textbox></td>
> > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > > BackColor="#F6CD7A"
> > > > BorderStyle="Solid" BorderWidth="1px"
> > > > Width="80px"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
> > > > TextMode="MultiLine"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
runat="server"
> > > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > > </TD></tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbox id="txtOutcome"
runat="server"></asp:textbox></td>
> > > > <td><asp:button id="cmdAddOutcome" runat="server"
Text="Add" > > > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > > BorderWidth="1px" Width="80px"
> > > > CausesValidation="False"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
> GridLines="None"
> > > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%# > > > > DatasetOutcomes1 %>">
> > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > <Columns>
> > > > <asp:TemplateColumn>
> > > > <ItemTemplate>
> > > > <ul>
> > > > <li>
> > > > </li>
> > > > </ul>
> > > > </ItemTemplate>
> > > > </asp:TemplateColumn>
> > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
> > > > HeaderText="Name"></asp:BoundColumn>
> > > > <asp:BoundColumn DataField="DisplayOrder"
> > > > SortExpression="DisplayOrder"
> > HeaderText="DisplayOrder"></asp:BoundColumn>
> > > > <asp:ButtonColumn Text="Delete"
> > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > <asp:ButtonColumn Text="Edit"
> > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > </Columns>
> > > > </asp:datagrid></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > > runat="server"></asp:label></td>
> > > > </tr>
> > > > </table>
> > > > </form>
> > > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > > <!-- #INCLUDE file="footer.inc" -->
> > > >
> > > >
> > > > Code Bind:
> > > >
> > > > Imports System
> > > > Imports System.IO
> > > > Imports System.Xml
> > > >
> > > >
> > > > Public Class course_new
> > > > Inherits System.Web.UI.Page
> > > >
> > > > #Region " Web Form Designer Generated Code "
> > > >
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > > InitializeComponent()
> > > > Me.DatasetOutcomes1 = New
> > _1137InsetBookingSystem.DatasetOutcomes
> > > > CType(Me.DatasetOutcomes1,
> > > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > > '
> > > > 'DatasetOutcomes1
> > > > '
> > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > > > Me.DatasetOutcomes1.Locale = New
> > > > System.Globalization.CultureInfo("en-GB")
> > > > CType(Me.DatasetOutcomes1,
> > > > System.ComponentModel.ISupportInitialize).EndInit( )
> > > >
> > > > End Sub
> > > > Protected WithEvents lblCourseTitle As
> > System.Web.UI.WebControls.Label
> > > > Protected WithEvents txtCourseTitle As
> > > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents txtCourseTutor As
> > > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents txtTutorList As
> > System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents cmdAdd As

System.Web.UI.WebControls.Button
> > > > Protected WithEvents txtOutcome As
> System.Web.UI.WebControls.TextBox
> > > > Protected WithEvents cmdAddOutcome As
> > System.Web.UI.WebControls.Button
> > > > Protected WithEvents lblCourseTutorList As
> > > > System.Web.UI.WebControls.Label
> > > > Protected WithEvents lblLearningOutcomes As
> > > > System.Web.UI.WebControls.Label
> > > > Protected WithEvents DataGridOutcomes As
> > > > System.Web.UI.WebControls.DataGrid
> > > > Protected WithEvents DatasetOutcomes1 As
> > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > Protected WithEvents lblOutcomes As
> System.Web.UI.WebControls.Label
> > > >
> > > > 'NOTE: The following placeholder declaration is required
by the
> Web
> > > Form
> > > > Designer.
> > > > 'Do not delete or move it.
> > > > Private designerPlaceholderDeclaration As System.Object
> > > >
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArgs) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeComponent()
> > > > End Sub
> > > >
> > > > #End Region
> > > > Public gstrTableTitle As String = "Create Course"
> > > > Public gstrTableAttribs As String
> > > >
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArgs) Handles MyBase.Load
> > > > 'Put user code to initialize the page here
> > > > If Not Page.IsPostBack Then
> > > > Me.DataGridOutcomes.DataBind()
> > > > Else
> > > > Dim str As String = Me.lblOutcomes.Text
> > > > Dim MyStream As StreamReader
> > > >
> > > > If str.Length > 0 Then
> > > > MyStream = New StreamReader(str)
> > > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > 'Me.DatasetOutcomes1.GetXml()
> > > > '
> > > >
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub UpdateOutcomes()
> > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > > > Me.DataGridOutcomes.DataBind()
> > > > End Sub
> > > >
> > > > Private Sub cmdAdd_Click(ByVal sender As System.Object,

ByVal
e
As
> > > > System.EventArgs) Handles cmdAdd.Click
> > > >
> > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text)

< 1 > Then
> > > > If Me.txtTutorList.Text.Length > 0 Then
> > > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"
&
> > vbCrLf
> > > &
> > > > Me.txtCourseTutor.Text
> > > > Else
> > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
> > > > End If
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub cmdAddOutcome_Click(ByVal sender As

System.Object, > ByVal
> > e
> > > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > > Dim dr As DatasetOutcomes.OutcomesRow
> > > >
> > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > > dr.Item("Name") = Me.txtOutcome.Text
> > > > dr.Item("DisplayOrder") =
> > Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > > >
> > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > > Me.DataGridOutcomes.DataBind()
> > > >
> > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > > >
> > > > End Sub
> > > >
> > > > End Class
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #10

P: n/a
It will eventually be written to a SQL DB but each of the data grid items
will relate to the new course record. As such the course details need top be
completed on the form.Once all the course details have been captured the
data will be split into several tables. Each of the outcome rows will relate
to one course record and will be held in a table call tblCourseOutcomes. I
did want to get into a situation of create temp record in the DB.
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Runs on multiple servers - and no Sql Server database to store session state in.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
Ok, I don't think I've ever used an updateable XML file yet, so I didn't
see
that. In order to update even a single row, you have to read in the entire file.

Please pardon me for being dense, was your question ever actually answered?
:-)

If I were you, I think I'd store DatasetCourse in Session state. On
the other hand, if you're going to be making multiple changes to the data per session, I think I'd keep it in Session, but flush to disk whenever a

change
was made. That way, if the session expires (seen as

Session("DatasetCourse")
Is Nothing), then you can re-load it from the disk file (which you'll need to uniquely name, without resorting to the Session ID!)
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> DatasetCourse is linked to an xml schema to define the data structure and
> the data its self is an xml doc. There is no database behind it,
hence
the
> need to repopulate from the xml data on postback.
>
>
> Schema:
> <?xml version="1.0" encoding="utf-8" ?>
> <xs:schema id="DatasetOutcomes"
> targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
> elementFormDefault="qualified"
> attributeFormDefault="qualified"
>

xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
> <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element name="Outcomes">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="Description" type="xs:string" minOccurs="0"

/> > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" /> > </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:choice>
> </xs:complexType>
> <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
> <xs:selector xpath=".//mstns:Outcomes" />
> <xs:field xpath="mstns:Description" />
> </xs:key>
> </xs:element>
> </xs:schema>
>
>
> "John Saunders" <jo***********@surfcontrol.com> wrote in message
> news:u1**************@TK2MSFTNGP09.phx.gbl...
> > James,
> >
> > I'm glad you solved your problem, but I'm wondering how you use
> > DatasetCourse on postbacks?
> > --
> > John Saunders
> > Internet Engineer
> > jo***********@surfcontrol.com
> >
> > "James Norton-Jones" <ja****************@stopford.com> wrote in

message
> > news:3f***********************@news.easynet.co.uk. ..
> > > Managed to solve it using:
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > If Not Page.IsPostBack Then
> > >
> > > Me.DataGridOutcomes.DataBind()
> > > Else
> > > 'Create the XML fragment to be parsed.
> > > Dim xmlFrag As String = Me.lblOutcomes.Text
> > >
> > > If xmlFrag.Length > 0 Then
> > >
> > > 'Create the XmlNamespaceManager.
> > > Dim nt As NameTable = New NameTable
> > > Dim nsmgr As XmlNamespaceManager = New
> > > XmlNamespaceManager(nt)
> > >
> > > 'Create the XmlParserContext.
> > > Dim context As XmlParserContext = New
> > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
> > >
> > > 'Create the reader.
> > > Dim xmlTR As XmlTextReader = New
XmlTextReader(xmlFrag,
> > > XmlNodeType.Element, context)
> > >
> > > Me.DatasetCourse.ReadXml(xmlTR)
> > >
> > > End If
> > > End If
> > > End Sub
> > >
> > >
> > > "John Saunders" <jo***********@surfcontrol.com> wrote in message
> > > news:OP**************@TK2MSFTNGP09.phx.gbl...
> > > > Most of the time, your code can follow this pattern:
> > > >
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As > > > > System.EventArgs) Handles MyBase.Load
> > > > If Not Page.IsPostBack Then
> > > > myDataSet = GetDataSetSomeHow()
> > > > myDataGrid.DataSource = myDataSet
> > > > myDataGrid.DataMember = "FirstTable"
> > > >
> > > > DataBind()
> > > > End If
> > > > End Sub
> > > >
> > > > When the page is posted back, the grid (or other controls) will > populate
> > > > itself from ViewState.
> > > > --
> > > > John Saunders
> > > > Internet Engineer
> > > > jo***********@surfcontrol.com
> > > >
> > > >
> > > > "James Norton-Jones" <ja****************@stopford.com> wrote in > message
> > > > news:3f***********************@news.easynet.co.uk. ..
> > > > > Hi,
> > > > >
> > > > > Am I trying to hold the data of a DataGrid in a label so that when
> the
> > > > form
> > > > > is reposted the DataGrid can be repopulated. The problem I
am having
> > is
> > > > that
> > > > > I don't understand how to get the text into a stream in order to be
> > able
> > > > to
> > > > > use DataSetOutcomes1.ReadXML(MyStream).
> > > > >
> > > > > Thanks in advance,
> > > > >
> > > > > James
> > > > >
> > > > >
> > > > > Web Form:
> > > > >
> > > > > <%@ Page Language="vb" AutoEventWireup="false"
> > > > > Codebehind="course_new.aspx.vb"
> > > > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > > > <!-- #INCLUDE file="tableheader.inc" -->
> > > > > <form id="FormNewCourse" method="post" runat="server">
> > > > > <table cellSpacing="0" cols="3" cellPadding="0"
width="100%" > > > border="0">
> > > > > <tr>
> > > > > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
> > > > > Font-Bold="True">Course Title</asp:label></td>
> > > > > <td><asp:textbox id="txtCourseTitle"
> > > runat="server"></asp:textbox></td>
> > > > > <td>&nbsp;</td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
runat="server"
> > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td vAlign="top">&nbsp;</td>
> > > > > <td><asp:textbox id="txtCourseTutor"
> > > runat="server"></asp:textbox></td>
> > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > > > BackColor="#F6CD7A"
> > > > > BorderStyle="Solid" BorderWidth="1px"
> > > > > Width="80px"></asp:button></td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td>&nbsp;</td>
> > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5" > > > > > TextMode="MultiLine"></asp:textbox></td>
> > > > > <td>&nbsp;</td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
> runat="server"
> > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > > > </TD></tr>
> > > > > <tr>
> > > > > <td>&nbsp;</td>
> > > > > <td><asp:textbox id="txtOutcome"
> runat="server"></asp:textbox></td>
> > > > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add" > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > > > BorderWidth="1px" Width="80px"
> > > > > CausesValidation="False"></asp:button></td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td>&nbsp;</td>
> > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
> > GridLines="None"
> > > > > AutoGenerateColumns="False" DataMember="Outcomes"

DataSource="<%#
> > > > > DatasetOutcomes1 %>">
> > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > > <Columns>
> > > > > <asp:TemplateColumn>
> > > > > <ItemTemplate>
> > > > > <ul>
> > > > > <li>
> > > > > </li>
> > > > > </ul>
> > > > > </ItemTemplate>
> > > > > </asp:TemplateColumn>
> > > > > <asp:BoundColumn DataField="Name" SortExpression="Name" > > > > > HeaderText="Name"></asp:BoundColumn>
> > > > > <asp:BoundColumn DataField="DisplayOrder"
> > > > > SortExpression="DisplayOrder"
> > > HeaderText="DisplayOrder"></asp:BoundColumn>
> > > > > <asp:ButtonColumn Text="Delete"
> > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > <asp:ButtonColumn Text="Edit"
> > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > </Columns>
> > > > > </asp:datagrid></td>
> > > > > <td>&nbsp;</td>
> > > > > </tr>
> > > > > <tr>
> > > > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > > > runat="server"></asp:label></td>
> > > > > </tr>
> > > > > </table>
> > > > > </form>
> > > > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > > > <!-- #INCLUDE file="footer.inc" -->
> > > > >
> > > > >
> > > > > Code Bind:
> > > > >
> > > > > Imports System
> > > > > Imports System.IO
> > > > > Imports System.Xml
> > > > >
> > > > >
> > > > > Public Class course_new
> > > > > Inherits System.Web.UI.Page
> > > > >
> > > > > #Region " Web Form Designer Generated Code "
> > > > >
> > > > > 'This call is required by the Web Form Designer.
> > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > > > InitializeComponent()
> > > > > Me.DatasetOutcomes1 = New
> > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > CType(Me.DatasetOutcomes1,
> > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > > > '
> > > > > 'DatasetOutcomes1
> > > > > '
> > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
> > > > > Me.DatasetOutcomes1.Locale = New
> > > > > System.Globalization.CultureInfo("en-GB")
> > > > > CType(Me.DatasetOutcomes1,
> > > > > System.ComponentModel.ISupportInitialize).EndInit( )
> > > > >
> > > > > End Sub
> > > > > Protected WithEvents lblCourseTitle As
> > > System.Web.UI.WebControls.Label
> > > > > Protected WithEvents txtCourseTitle As
> > > > System.Web.UI.WebControls.TextBox
> > > > > Protected WithEvents txtCourseTutor As
> > > > System.Web.UI.WebControls.TextBox
> > > > > Protected WithEvents txtTutorList As
> > > System.Web.UI.WebControls.TextBox
> > > > > Protected WithEvents cmdAdd As
System.Web.UI.WebControls.Button
> > > > > Protected WithEvents txtOutcome As
> > System.Web.UI.WebControls.TextBox
> > > > > Protected WithEvents cmdAddOutcome As
> > > System.Web.UI.WebControls.Button
> > > > > Protected WithEvents lblCourseTutorList As
> > > > > System.Web.UI.WebControls.Label
> > > > > Protected WithEvents lblLearningOutcomes As
> > > > > System.Web.UI.WebControls.Label
> > > > > Protected WithEvents DataGridOutcomes As
> > > > > System.Web.UI.WebControls.DataGrid
> > > > > Protected WithEvents DatasetOutcomes1 As
> > > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > Protected WithEvents lblOutcomes As
> > System.Web.UI.WebControls.Label
> > > > >
> > > > > 'NOTE: The following placeholder declaration is required by the
> > Web
> > > > Form
> > > > > Designer.
> > > > > 'Do not delete or move it.
> > > > > Private designerPlaceholderDeclaration As System.Object
> > > > >
> > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As
> > > > > System.EventArgs) Handles MyBase.Init
> > > > > 'CODEGEN: This method call is required by the Web
Form > > Designer
> > > > > 'Do not modify it using the code editor.
> > > > > InitializeComponent()
> > > > > End Sub
> > > > >
> > > > > #End Region
> > > > > Public gstrTableTitle As String = "Create Course"
> > > > > Public gstrTableAttribs As String
> > > > >
> > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > > System.EventArgs) Handles MyBase.Load
> > > > > 'Put user code to initialize the page here
> > > > > If Not Page.IsPostBack Then
> > > > > Me.DataGridOutcomes.DataBind()
> > > > > Else
> > > > > Dim str As String = Me.lblOutcomes.Text
> > > > > Dim MyStream As StreamReader
> > > > >
> > > > > If str.Length > 0 Then
> > > > > MyStream = New StreamReader(str)
> > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > > > >
> > > > > End If
> > > > >
> > > > >
> > > > >
> > > > > 'Me.DatasetOutcomes1.GetXml()
> > > > > '
> > > > >
> > > > > End If
> > > > > End Sub
> > > > >
> > > > > Private Sub UpdateOutcomes()
> > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
> > > > > Me.DataGridOutcomes.DataBind()
> > > > > End Sub
> > > > >
> > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal
e
> As
> > > > > System.EventArgs) Handles cmdAdd.Click
> > > > >
> > > > > If InStr(Me.txtTutorList.Text,

Me.txtCourseTutor.Text) <
1
> > Then
> > > > > If Me.txtTutorList.Text.Length > 0 Then
> > > > > Me.txtTutorList.Text = Me.txtTutorList.Text

& ";"
&
> > > vbCrLf
> > > > &
> > > > > Me.txtCourseTutor.Text
> > > > > Else
> > > > > Me.txtTutorList.Text =

Me.txtCourseTutor.Text > > > > > End If
> > > > > End If
> > > > > End Sub
> > > > >
> > > > > Private Sub cmdAddOutcome_Click(ByVal sender As

System.Object,
> > ByVal
> > > e
> > > > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > > > Dim dr As DatasetOutcomes.OutcomesRow
> > > > >
> > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > > > dr.Item("Name") = Me.txtOutcome.Text
> > > > > dr.Item("DisplayOrder") =
> > > Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > > > >
> > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > > > Me.DataGridOutcomes.DataBind()
> > > > >
> > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > > > >
> > > > > End Sub
> > > > >
> > > > > End Class
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #11

P: n/a
Oh, if there is a Sql Server database, had you considered using the
"SQLServer" mode of the <sessionState> element in web.config? I haven't
tried it - perhaps it's too slow.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
It will eventually be written to a SQL DB but each of the data grid items
will relate to the new course record. As such the course details need top be completed on the form.Once all the course details have been captured the
data will be split into several tables. Each of the outcome rows will relate to one course record and will be held in a table call tblCourseOutcomes. I
did want to get into a situation of create temp record in the DB.
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Runs on multiple servers - and no Sql Server database to store session state
in.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
Session:

Not able to do that as it will run on multiple servers.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:uh**************@TK2MSFTNGP12.phx.gbl...
> Ok, I don't think I've ever used an updateable XML file yet, so I didn't see
> that. In order to update even a single row, you have to read in the

entire
> file.
>
> Please pardon me for being dense, was your question ever actually
answered?
> :-)
>
> If I were you, I think I'd store DatasetCourse in Session state. On the > other hand, if you're going to be making multiple changes to the data
per
> session, I think I'd keep it in Session, but flush to disk whenever
a change
> was made. That way, if the session expires (seen as
Session("DatasetCourse")
> Is Nothing), then you can re-load it from the disk file (which you'll
need
> to uniquely name, without resorting to the Session ID!)
> --
> John Saunders
> Internet Engineer
> jo***********@surfcontrol.com
>
> "James Norton-Jones" <ja****************@stopford.com> wrote in message > news:3f***********************@news.easynet.co.uk. ..
> > DatasetCourse is linked to an xml schema to define the data structure and
> > the data its self is an xml doc. There is no database behind it, hence the
> > need to repopulate from the xml data on postback.
> >
> >
> > Schema:
> > <?xml version="1.0" encoding="utf-8" ?>
> > <xs:schema id="DatasetOutcomes"
> > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
> > elementFormDefault="qualified"
> > attributeFormDefault="qualified"
> >
xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
> > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
> > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
> > <xs:complexType>
> > <xs:choice maxOccurs="unbounded">
> > <xs:element name="Outcomes">
> > <xs:complexType>
> > <xs:sequence>
> > <xs:element name="Description" type="xs:string"
minOccurs="0" />
> > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" /> > > </xs:sequence>
> > </xs:complexType>
> > </xs:element>
> > </xs:choice>
> > </xs:complexType>
> > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
> > <xs:selector xpath=".//mstns:Outcomes" />
> > <xs:field xpath="mstns:Description" />
> > </xs:key>
> > </xs:element>
> > </xs:schema>
> >
> >
> > "John Saunders" <jo***********@surfcontrol.com> wrote in message
> > news:u1**************@TK2MSFTNGP09.phx.gbl...
> > > James,
> > >
> > > I'm glad you solved your problem, but I'm wondering how you use
> > > DatasetCourse on postbacks?
> > > --
> > > John Saunders
> > > Internet Engineer
> > > jo***********@surfcontrol.com
> > >
> > > "James Norton-Jones" <ja****************@stopford.com> wrote in
message
> > > news:3f***********************@news.easynet.co.uk. ..
> > > > Managed to solve it using:
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArgs) Handles MyBase.Load
> > > > 'Put user code to initialize the page here
> > > > If Not Page.IsPostBack Then
> > > >
> > > > Me.DataGridOutcomes.DataBind()
> > > > Else
> > > > 'Create the XML fragment to be parsed.
> > > > Dim xmlFrag As String = Me.lblOutcomes.Text
> > > >
> > > > If xmlFrag.Length > 0 Then
> > > >
> > > > 'Create the XmlNamespaceManager.
> > > > Dim nt As NameTable = New NameTable
> > > > Dim nsmgr As XmlNamespaceManager = New
> > > > XmlNamespaceManager(nt)
> > > >
> > > > 'Create the XmlParserContext.
> > > > Dim context As XmlParserContext = New
> > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
> > > >
> > > > 'Create the reader.
> > > > Dim xmlTR As XmlTextReader = New
> XmlTextReader(xmlFrag,
> > > > XmlNodeType.Element, context)
> > > >
> > > > Me.DatasetCourse.ReadXml(xmlTR)
> > > >
> > > > End If
> > > > End If
> > > > End Sub
> > > >
> > > >
> > > > "John Saunders" <jo***********@surfcontrol.com> wrote in
message > > > > news:OP**************@TK2MSFTNGP09.phx.gbl...
> > > > > Most of the time, your code can follow this pattern:
> > > > >
> > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a

As > > > > > System.EventArgs) Handles MyBase.Load
> > > > > If Not Page.IsPostBack Then
> > > > > myDataSet = GetDataSetSomeHow()
> > > > > myDataGrid.DataSource = myDataSet
> > > > > myDataGrid.DataMember = "FirstTable"
> > > > >
> > > > > DataBind()
> > > > > End If
> > > > > End Sub
> > > > >
> > > > > When the page is posted back, the grid (or other controls) will > > populate
> > > > > itself from ViewState.
> > > > > --
> > > > > John Saunders
> > > > > Internet Engineer
> > > > > jo***********@surfcontrol.com
> > > > >
> > > > >
> > > > > "James Norton-Jones" <ja****************@stopford.com> wrote in > > message
> > > > > news:3f***********************@news.easynet.co.uk. ..
> > > > > > Hi,
> > > > > >
> > > > > > Am I trying to hold the data of a DataGrid in a label so that when
> > the
> > > > > form
> > > > > > is reposted the DataGrid can be repopulated. The problem I am > having
> > > is
> > > > > that
> > > > > > I don't understand how to get the text into a stream in order
to
> be
> > > able
> > > > > to
> > > > > > use DataSetOutcomes1.ReadXML(MyStream).
> > > > > >
> > > > > > Thanks in advance,
> > > > > >
> > > > > > James
> > > > > >
> > > > > >
> > > > > > Web Form:
> > > > > >
> > > > > > <%@ Page Language="vb" AutoEventWireup="false"
> > > > > > Codebehind="course_new.aspx.vb"
> > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > > > > <!-- #INCLUDE file="tableheader.inc" -->
> > > > > > <form id="FormNewCourse" method="post" runat="server">
> > > > > > <table cellSpacing="0" cols="3" cellPadding="0"

width="100%" > > > > border="0">
> > > > > > <tr>
> > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
runat="server"
> > > > > > Font-Bold="True">Course Title</asp:label></td>
> > > > > > <td><asp:textbox id="txtCourseTitle"
> > > > runat="server"></asp:textbox></td>
> > > > > > <td>&nbsp;</td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
> runat="server"
> > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td vAlign="top">&nbsp;</td>
> > > > > > <td><asp:textbox id="txtCourseTutor"
> > > > runat="server"></asp:textbox></td>
> > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > > > > BackColor="#F6CD7A"
> > > > > > BorderStyle="Solid" BorderWidth="1px"
> > > > > > Width="80px"></asp:button></td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td>&nbsp;</td>
> > > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5" > > > > > > TextMode="MultiLine"></asp:textbox></td>
> > > > > > <td>&nbsp;</td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
> > runat="server"
> > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > > > > </TD></tr>
> > > > > > <tr>
> > > > > > <td>&nbsp;</td>
> > > > > > <td><asp:textbox id="txtOutcome"
> > runat="server"></asp:textbox></td>
> > > > > > <td><asp:button id="cmdAddOutcome" runat="server"

Text="Add"
> > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > > > > BorderWidth="1px" Width="80px"
> > > > > > CausesValidation="False"></asp:button></td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td>&nbsp;</td>
> > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
> > > GridLines="None"
> > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
DataSource="<%#
> > > > > > DatasetOutcomes1 %>">
> > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > > > <Columns>
> > > > > > <asp:TemplateColumn>
> > > > > > <ItemTemplate>
> > > > > > <ul>
> > > > > > <li>
> > > > > > </li>
> > > > > > </ul>
> > > > > > </ItemTemplate>
> > > > > > </asp:TemplateColumn>
> > > > > > <asp:BoundColumn DataField="Name" SortExpression="Name" > > > > > > HeaderText="Name"></asp:BoundColumn>
> > > > > > <asp:BoundColumn DataField="DisplayOrder"
> > > > > > SortExpression="DisplayOrder"
> > > > HeaderText="DisplayOrder"></asp:BoundColumn>
> > > > > > <asp:ButtonColumn Text="Delete"
> > > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > > <asp:ButtonColumn Text="Edit"
> > > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > > </Columns>
> > > > > > </asp:datagrid></td>
> > > > > > <td>&nbsp;</td>
> > > > > > </tr>
> > > > > > <tr>
> > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > > > > runat="server"></asp:label></td>
> > > > > > </tr>
> > > > > > </table>
> > > > > > </form>
> > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > > > > <!-- #INCLUDE file="footer.inc" -->
> > > > > >
> > > > > >
> > > > > > Code Bind:
> > > > > >
> > > > > > Imports System
> > > > > > Imports System.IO
> > > > > > Imports System.Xml
> > > > > >
> > > > > >
> > > > > > Public Class course_new
> > > > > > Inherits System.Web.UI.Page
> > > > > >
> > > > > > #Region " Web Form Designer Generated Code "
> > > > > >
> > > > > > 'This call is required by the Web Form Designer.
> > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > > > > > InitializeComponent()
> > > > > > Me.DatasetOutcomes1 = New
> > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > > CType(Me.DatasetOutcomes1,
> > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > > > > '
> > > > > > 'DatasetOutcomes1
> > > > > > '
> > > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes" > > > > > > Me.DatasetOutcomes1.Locale = New
> > > > > > System.Globalization.CultureInfo("en-GB")
> > > > > > CType(Me.DatasetOutcomes1,
> > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
> > > > > >
> > > > > > End Sub
> > > > > > Protected WithEvents lblCourseTitle As
> > > > System.Web.UI.WebControls.Label
> > > > > > Protected WithEvents txtCourseTitle As
> > > > > System.Web.UI.WebControls.TextBox
> > > > > > Protected WithEvents txtCourseTutor As
> > > > > System.Web.UI.WebControls.TextBox
> > > > > > Protected WithEvents txtTutorList As
> > > > System.Web.UI.WebControls.TextBox
> > > > > > Protected WithEvents cmdAdd As
> System.Web.UI.WebControls.Button
> > > > > > Protected WithEvents txtOutcome As
> > > System.Web.UI.WebControls.TextBox
> > > > > > Protected WithEvents cmdAddOutcome As
> > > > System.Web.UI.WebControls.Button
> > > > > > Protected WithEvents lblCourseTutorList As
> > > > > > System.Web.UI.WebControls.Label
> > > > > > Protected WithEvents lblLearningOutcomes As
> > > > > > System.Web.UI.WebControls.Label
> > > > > > Protected WithEvents DataGridOutcomes As
> > > > > > System.Web.UI.WebControls.DataGrid
> > > > > > Protected WithEvents DatasetOutcomes1 As
> > > > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > > Protected WithEvents lblOutcomes As
> > > System.Web.UI.WebControls.Label
> > > > > >
> > > > > > 'NOTE: The following placeholder declaration is required by
> the
> > > Web
> > > > > Form
> > > > > > Designer.
> > > > > > 'Do not delete or move it.
> > > > > > Private designerPlaceholderDeclaration As
System.Object > > > > > >
> > > > > > Private Sub Page_Init(ByVal sender As System.Object,

ByVal
e
> As
> > > > > > System.EventArgs) Handles MyBase.Init
> > > > > > 'CODEGEN: This method call is required by the Web

Form > > > Designer
> > > > > > 'Do not modify it using the code editor.
> > > > > > InitializeComponent()
> > > > > > End Sub
> > > > > >
> > > > > > #End Region
> > > > > > Public gstrTableTitle As String = "Create Course"
> > > > > > Public gstrTableAttribs As String
> > > > > >
> > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e
> As
> > > > > > System.EventArgs) Handles MyBase.Load
> > > > > > 'Put user code to initialize the page here
> > > > > > If Not Page.IsPostBack Then
> > > > > > Me.DataGridOutcomes.DataBind()
> > > > > > Else
> > > > > > Dim str As String = Me.lblOutcomes.Text
> > > > > > Dim MyStream As StreamReader
> > > > > >
> > > > > > If str.Length > 0 Then
> > > > > > MyStream = New StreamReader(str)
> > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > > > > >
> > > > > > End If
> > > > > >
> > > > > >
> > > > > >
> > > > > > 'Me.DatasetOutcomes1.GetXml()
> > > > > > '
> > > > > >
> > > > > > End If
> > > > > > End Sub
> > > > > >
> > > > > > Private Sub UpdateOutcomes()
> > > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1 > > > > > > Me.DataGridOutcomes.DataBind()
> > > > > > End Sub
> > > > > >
> > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal
> e
> > As
> > > > > > System.EventArgs) Handles cmdAdd.Click
> > > > > >
> > > > > > If InStr(Me.txtTutorList.Text,

Me.txtCourseTutor.Text)
<
1
> > > Then
> > > > > > If Me.txtTutorList.Text.Length > 0 Then
> > > > > > Me.txtTutorList.Text =

Me.txtTutorList.Text & ";"
> &
> > > > vbCrLf
> > > > > &
> > > > > > Me.txtCourseTutor.Text
> > > > > > Else
> > > > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text > > > > > > End If
> > > > > > End If
> > > > > > End Sub
> > > > > >
> > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
System.Object,
> > > ByVal
> > > > e
> > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > > > > Dim dr As DatasetOutcomes.OutcomesRow
> > > > > >
> > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > > > > dr.Item("Name") = Me.txtOutcome.Text
> > > > > > dr.Item("DisplayOrder") =
> > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > > > > >
> > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > > > > Me.DataGridOutcomes.DataBind()
> > > > > >
> > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > > > > >
> > > > > > End Sub
> > > > > >
> > > > > > End Class
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #12

P: n/a
To be honest I didn't know it existed, I'll look into it thanks. It would
certainly reduce the HTML payload.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:un*************@TK2MSFTNGP10.phx.gbl...
Oh, if there is a Sql Server database, had you considered using the
"SQLServer" mode of the <sessionState> element in web.config? I haven't
tried it - perhaps it's too slow.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message
news:3f***********************@news.easynet.co.uk. ..
It will eventually be written to a SQL DB but each of the data grid items
will relate to the new course record. As such the course details need top
be
completed on the form.Once all the course details have been captured the
data will be split into several tables. Each of the outcome rows will relate
to one course record and will be held in a table call tblCourseOutcomes.

I did want to get into a situation of create temp record in the DB.
"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Runs on multiple servers - and no Sql Server database to store session

state
in.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"James Norton-Jones" <ja****************@stopford.com> wrote in message news:3f***********************@news.easynet.co.uk. ..
> Session:
>
> Not able to do that as it will run on multiple servers.
>
> "John Saunders" <jo***********@surfcontrol.com> wrote in message
> news:uh**************@TK2MSFTNGP12.phx.gbl...
> > Ok, I don't think I've ever used an updateable XML file yet, so I

didn't
> see
> > that. In order to update even a single row, you have to read in the entire
> > file.
> >
> > Please pardon me for being dense, was your question ever actually
> answered?
> > :-)
> >
> > If I were you, I think I'd store DatasetCourse in Session state. On
the
> > other hand, if you're going to be making multiple changes to the data per
> > session, I think I'd keep it in Session, but flush to disk
whenever a > change
> > was made. That way, if the session expires (seen as
> Session("DatasetCourse")
> > Is Nothing), then you can re-load it from the disk file (which you'll need
> > to uniquely name, without resorting to the Session ID!)
> > --
> > John Saunders
> > Internet Engineer
> > jo***********@surfcontrol.com
> >
> > "James Norton-Jones" <ja****************@stopford.com> wrote in message
> > news:3f***********************@news.easynet.co.uk. ..
> > > DatasetCourse is linked to an xml schema to define the data

structure
> and
> > > the data its self is an xml doc. There is no database behind it,

hence
> the
> > > need to repopulate from the xml data on postback.
> > >
> > >
> > > Schema:
> > > <?xml version="1.0" encoding="utf-8" ?>
> > > <xs:schema id="DatasetOutcomes"
> > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
> > > elementFormDefault="qualified"
> > > attributeFormDefault="qualified"
> > >
>

xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd" > > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
> > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
> > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
> > > <xs:complexType>
> > > <xs:choice maxOccurs="unbounded">
> > > <xs:element name="Outcomes">
> > > <xs:complexType>
> > > <xs:sequence>
> > > <xs:element name="Description" type="xs:string"

minOccurs="0" />
> > > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
> > > </xs:sequence>
> > > </xs:complexType>
> > > </xs:element>
> > > </xs:choice>
> > > </xs:complexType>
> > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
> > > <xs:selector xpath=".//mstns:Outcomes" />
> > > <xs:field xpath="mstns:Description" />
> > > </xs:key>
> > > </xs:element>
> > > </xs:schema>
> > >
> > >
> > > "John Saunders" <jo***********@surfcontrol.com> wrote in message
> > > news:u1**************@TK2MSFTNGP09.phx.gbl...
> > > > James,
> > > >
> > > > I'm glad you solved your problem, but I'm wondering how you
use > > > > DatasetCourse on postbacks?
> > > > --
> > > > John Saunders
> > > > Internet Engineer
> > > > jo***********@surfcontrol.com
> > > >
> > > > "James Norton-Jones" <ja****************@stopford.com> wrote in > message
> > > > news:3f***********************@news.easynet.co.uk. ..
> > > > > Managed to solve it using:
> > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > > > > System.EventArgs) Handles MyBase.Load
> > > > > 'Put user code to initialize the page here
> > > > > If Not Page.IsPostBack Then
> > > > >
> > > > > Me.DataGridOutcomes.DataBind()
> > > > > Else
> > > > > 'Create the XML fragment to be parsed.
> > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
> > > > >
> > > > > If xmlFrag.Length > 0 Then
> > > > >
> > > > > 'Create the XmlNamespaceManager.
> > > > > Dim nt As NameTable = New NameTable
> > > > > Dim nsmgr As XmlNamespaceManager = New
> > > > > XmlNamespaceManager(nt)
> > > > >
> > > > > 'Create the XmlParserContext.
> > > > > Dim context As XmlParserContext = New
> > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
> > > > >
> > > > > 'Create the reader.
> > > > > Dim xmlTR As XmlTextReader = New
> > XmlTextReader(xmlFrag,
> > > > > XmlNodeType.Element, context)
> > > > >
> > > > > Me.DatasetCourse.ReadXml(xmlTR)
> > > > >
> > > > > End If
> > > > > End If
> > > > > End Sub
> > > > >
> > > > >
> > > > > "John Saunders" <jo***********@surfcontrol.com> wrote in message > > > > > news:OP**************@TK2MSFTNGP09.phx.gbl...
> > > > > > Most of the time, your code can follow this pattern:
> > > > > >
> > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
a
As
> > > > > > System.EventArgs) Handles MyBase.Load
> > > > > > If Not Page.IsPostBack Then
> > > > > > myDataSet = GetDataSetSomeHow()
> > > > > > myDataGrid.DataSource = myDataSet
> > > > > > myDataGrid.DataMember = "FirstTable"
> > > > > >
> > > > > > DataBind()
> > > > > > End If
> > > > > > End Sub
> > > > > >
> > > > > > When the page is posted back, the grid (or other controls)

will
> > > populate
> > > > > > itself from ViewState.
> > > > > > --
> > > > > > John Saunders
> > > > > > Internet Engineer
> > > > > > jo***********@surfcontrol.com
> > > > > >
> > > > > >
> > > > > > "James Norton-Jones" <ja****************@stopford.com>
wrote in
> > > message
> > > > > > news:3f***********************@news.easynet.co.uk. ..
> > > > > > > Hi,
> > > > > > >
> > > > > > > Am I trying to hold the data of a DataGrid in a label so

that
> when
> > > the
> > > > > > form
> > > > > > > is reposted the DataGrid can be repopulated. The problem
I am
> > having
> > > > is
> > > > > > that
> > > > > > > I don't understand how to get the text into a stream in

order
to
> > be
> > > > able
> > > > > > to
> > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
> > > > > > >
> > > > > > > Thanks in advance,
> > > > > > >
> > > > > > > James
> > > > > > >
> > > > > > >
> > > > > > > Web Form:
> > > > > > >
> > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
> > > > > > > Codebehind="course_new.aspx.vb"
> > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
> > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
> > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
> > > > > > > <form id="FormNewCourse" method="post" runat="server">
> > > > > > > <table cellSpacing="0" cols="3" cellPadding="0"

width="100%"
> > > > > border="0">
> > > > > > > <tr>
> > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
> runat="server"
> > > > > > > Font-Bold="True">Course Title</asp:label></td>
> > > > > > > <td><asp:textbox id="txtCourseTitle"
> > > > > runat="server"></asp:textbox></td>
> > > > > > > <td>&nbsp;</td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
> > runat="server"
> > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td vAlign="top">&nbsp;</td>
> > > > > > > <td><asp:textbox id="txtCourseTutor"
> > > > > runat="server"></asp:textbox></td>
> > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
> > > > > > BackColor="#F6CD7A"
> > > > > > > BorderStyle="Solid" BorderWidth="1px"
> > > > > > > Width="80px"></asp:button></td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td>&nbsp;</td>
> > > > > > > <td><asp:textbox id="txtTutorList" runat="server"

Rows="5"
> > > > > > > TextMode="MultiLine"></asp:textbox></td>
> > > > > > > <td>&nbsp;</td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
> > > runat="server"
> > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
> > > > > > > </TD></tr>
> > > > > > > <tr>
> > > > > > > <td>&nbsp;</td>
> > > > > > > <td><asp:textbox id="txtOutcome"
> > > runat="server"></asp:textbox></td>
> > > > > > > <td><asp:button id="cmdAddOutcome" runat="server"
Text="Add"
> > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
> > > > > > > BorderWidth="1px" Width="80px"
> > > > > > > CausesValidation="False"></asp:button></td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td>&nbsp;</td>
> > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
> > > > GridLines="None"
> > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
> DataSource="<%#
> > > > > > > DatasetOutcomes1 %>">
> > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > > > > <Columns>
> > > > > > > <asp:TemplateColumn>
> > > > > > > <ItemTemplate>
> > > > > > > <ul>
> > > > > > > <li>
> > > > > > > </li>
> > > > > > > </ul>
> > > > > > > </ItemTemplate>
> > > > > > > </asp:TemplateColumn>
> > > > > > > <asp:BoundColumn DataField="Name"

SortExpression="Name"
> > > > > > > HeaderText="Name"></asp:BoundColumn>
> > > > > > > <asp:BoundColumn DataField="DisplayOrder"
> > > > > > > SortExpression="DisplayOrder"
> > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
> > > > > > > <asp:ButtonColumn Text="Delete"
> > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > > > <asp:ButtonColumn Text="Edit"
> > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
> > > > > > > </Columns>
> > > > > > > </asp:datagrid></td>
> > > > > > > <td>&nbsp;</td>
> > > > > > > </tr>
> > > > > > > <tr>
> > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
> > > > > > > runat="server"></asp:label></td>
> > > > > > > </tr>
> > > > > > > </table>
> > > > > > > </form>
> > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
> > > > > > > <!-- #INCLUDE file="footer.inc" -->
> > > > > > >
> > > > > > >
> > > > > > > Code Bind:
> > > > > > >
> > > > > > > Imports System
> > > > > > > Imports System.IO
> > > > > > > Imports System.Xml
> > > > > > >
> > > > > > >
> > > > > > > Public Class course_new
> > > > > > > Inherits System.Web.UI.Page
> > > > > > >
> > > > > > > #Region " Web Form Designer Generated Code "
> > > > > > >
> > > > > > > 'This call is required by the Web Form Designer.
> > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private
Sub > > > > > > > InitializeComponent()
> > > > > > > Me.DatasetOutcomes1 = New
> > > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > > > CType(Me.DatasetOutcomes1,
> > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
> > > > > > > '
> > > > > > > 'DatasetOutcomes1
> > > > > > > '
> > > > > > > Me.DatasetOutcomes1.DataSetName =

"DatasetOutcomes" > > > > > > > Me.DatasetOutcomes1.Locale = New
> > > > > > > System.Globalization.CultureInfo("en-GB")
> > > > > > > CType(Me.DatasetOutcomes1,
> > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
> > > > > > >
> > > > > > > End Sub
> > > > > > > Protected WithEvents lblCourseTitle As
> > > > > System.Web.UI.WebControls.Label
> > > > > > > Protected WithEvents txtCourseTitle As
> > > > > > System.Web.UI.WebControls.TextBox
> > > > > > > Protected WithEvents txtCourseTutor As
> > > > > > System.Web.UI.WebControls.TextBox
> > > > > > > Protected WithEvents txtTutorList As
> > > > > System.Web.UI.WebControls.TextBox
> > > > > > > Protected WithEvents cmdAdd As
> > System.Web.UI.WebControls.Button
> > > > > > > Protected WithEvents txtOutcome As
> > > > System.Web.UI.WebControls.TextBox
> > > > > > > Protected WithEvents cmdAddOutcome As
> > > > > System.Web.UI.WebControls.Button
> > > > > > > Protected WithEvents lblCourseTutorList As
> > > > > > > System.Web.UI.WebControls.Label
> > > > > > > Protected WithEvents lblLearningOutcomes As
> > > > > > > System.Web.UI.WebControls.Label
> > > > > > > Protected WithEvents DataGridOutcomes As
> > > > > > > System.Web.UI.WebControls.DataGrid
> > > > > > > Protected WithEvents DatasetOutcomes1 As
> > > > > > > _1137InsetBookingSystem.DatasetOutcomes
> > > > > > > Protected WithEvents lblOutcomes As
> > > > System.Web.UI.WebControls.Label
> > > > > > >
> > > > > > > 'NOTE: The following placeholder declaration is required by
> > the
> > > > Web
> > > > > > Form
> > > > > > > Designer.
> > > > > > > 'Do not delete or move it.
> > > > > > > Private designerPlaceholderDeclaration As System.Object > > > > > > >
> > > > > > > Private Sub Page_Init(ByVal sender As System.Object,

ByVal
e
> > As
> > > > > > > System.EventArgs) Handles MyBase.Init
> > > > > > > 'CODEGEN: This method call is required by the
Web Form
> > > > Designer
> > > > > > > 'Do not modify it using the code editor.
> > > > > > > InitializeComponent()
> > > > > > > End Sub
> > > > > > >
> > > > > > > #End Region
> > > > > > > Public gstrTableTitle As String = "Create Course"
> > > > > > > Public gstrTableAttribs As String
> > > > > > >
> > > > > > > Private Sub Page_Load(ByVal sender As System.Object,

ByVal
e
> > As
> > > > > > > System.EventArgs) Handles MyBase.Load
> > > > > > > 'Put user code to initialize the page here
> > > > > > > If Not Page.IsPostBack Then
> > > > > > > Me.DataGridOutcomes.DataBind()
> > > > > > > Else
> > > > > > > Dim str As String = Me.lblOutcomes.Text
> > > > > > > Dim MyStream As StreamReader
> > > > > > >
> > > > > > > If str.Length > 0 Then
> > > > > > > MyStream = New StreamReader(str)
> > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
> > > > > > >
> > > > > > > End If
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > 'Me.DatasetOutcomes1.GetXml()
> > > > > > > '
> > > > > > >
> > > > > > > End If
> > > > > > > End Sub
> > > > > > >
> > > > > > > Private Sub UpdateOutcomes()
> > > > > > > Me.DataGridOutcomes.DataSource =

Me.DatasetOutcomes1 > > > > > > > Me.DataGridOutcomes.DataBind()
> > > > > > > End Sub
> > > > > > >
> > > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object, > ByVal
> > e
> > > As
> > > > > > > System.EventArgs) Handles cmdAdd.Click
> > > > > > >
> > > > > > > If InStr(Me.txtTutorList.Text,

Me.txtCourseTutor.Text)
<
> 1
> > > > Then
> > > > > > > If Me.txtTutorList.Text.Length > 0 Then
> > > > > > > Me.txtTutorList.Text =

Me.txtTutorList.Text
&
> ";"
> > &
> > > > > vbCrLf
> > > > > > &
> > > > > > > Me.txtCourseTutor.Text
> > > > > > > Else
> > > > > > > Me.txtTutorList.Text =

Me.txtCourseTutor.Text
> > > > > > > End If
> > > > > > > End If
> > > > > > > End Sub
> > > > > > >
> > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
> System.Object,
> > > > ByVal
> > > > > e
> > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
> > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
> > > > > > >
> > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
> > > > > > > dr.Item("Name") = Me.txtOutcome.Text
> > > > > > > dr.Item("DisplayOrder") =
> > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
> > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
> > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
> > > > > > >
> > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
> > > > > > > Me.DataGridOutcomes.DataBind()
> > > > > > >
> > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
> > > > > > >
> > > > > > > End Sub
> > > > > > >
> > > > > > > End Class
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.