473,551 Members | 2,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 DataSetOutcomes 1.ReadXML(MyStr eam).

Thanks in advance,

James
Web Form:

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="cou rse_new.aspx.vb "
Inherits="_1137 InsetBookingSys tem.course_new" %>
<!-- #INCLUDE file="headerasp x.inc" -->
<!-- #INCLUDE file="tablehead er.inc" -->
<form id="FormNewCour se" method="post" runat="server">
<table cellSpacing="0" cols="3" cellPadding="0" width="100%" border="0">
<tr>
<td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
Font-Bold="True">Cou rse Title</asp:label></td>
<td><asp:textbo x id="txtCourseTi tle" runat="server"> </asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblCourseTu torList" runat="server"
Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
</tr>
<tr>
<td vAlign="top">&n bsp;</td>
<td><asp:textbo x id="txtCourseTu tor" runat="server"> </asp:textbox></td>
<td><asp:butt on id="cmdAdd" runat="server" Text="Add" BackColor="#F6C D7A"
BorderStyle="So lid" BorderWidth="1p x"
Width="80px"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
TextMode="Multi Line"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblLearning Outcomes" runat="server"
Font-Bold="True">Lea rning Outcomes</asp:label></td>
</TD></tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td>
<td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
BackColor="#F6C D7A" BorderStyle="So lid"
BorderWidth="1p x" Width="80px"
CausesValidatio n="False"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:datagr id id=DataGridOutc omes runat="server" GridLines="None "
AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
DatasetOutcomes 1 %>">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<ul>
<li>
</li>
</ul>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Name " SortExpression= "Name"
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="Disp layOrder"
SortExpression= "DisplayOrd er" HeaderText="Dis playOrder"></asp:BoundColumn >
<asp:ButtonColu mn Text="Delete"
ButtonType="Pus hButton"></asp:ButtonColum n>
<asp:ButtonColu mn Text="Edit"
ButtonType="Pus hButton"></asp:ButtonColum n>
</Columns>
</asp:datagrid></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblOutcomes "
runat="server"> </asp:label></td>
</tr>
</table>
</form>
<!-- #INCLUDE file="tablefoot er.inc" -->
<!-- #INCLUDE file="footer.in c" -->
Code Bind:

Imports System
Imports System.IO
Imports System.Xml
Public Class course_new
Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.DatasetOutco mes1 = New _1137InsetBooki ngSystem.Datase tOutcomes
CType(Me.Datase tOutcomes1,
System.Componen tModel.ISupport Initialize).Beg inInit()
'
'DatasetOutcome s1
'
Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
Me.DatasetOutco mes1.Locale = New
System.Globaliz ation.CultureIn fo("en-GB")
CType(Me.Datase tOutcomes1,
System.Componen tModel.ISupport Initialize).End Init()

End Sub
Protected WithEvents lblCourseTitle As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtCourseTitle As System.Web.UI.W ebControls.Text Box
Protected WithEvents txtCourseTutor As System.Web.UI.W ebControls.Text Box
Protected WithEvents txtTutorList As System.Web.UI.W ebControls.Text Box
Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on
Protected WithEvents txtOutcome As System.Web.UI.W ebControls.Text Box
Protected WithEvents cmdAddOutcome As System.Web.UI.W ebControls.Butt on
Protected WithEvents lblCourseTutorL ist As
System.Web.UI.W ebControls.Labe l
Protected WithEvents lblLearningOutc omes As
System.Web.UI.W ebControls.Labe l
Protected WithEvents DataGridOutcome s As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents DatasetOutcomes 1 As
_1137InsetBooki ngSystem.Datase tOutcomes
Protected WithEvents lblOutcomes As System.Web.UI.W ebControls.Labe l

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

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

#End Region
Public gstrTableTitle As String = "Create Course"
Public gstrTableAttrib s As String

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

If str.Length > 0 Then
MyStream = New StreamReader(st r)
Me.DatasetOutco mes1.ReadXml(My Stream)

End If

'Me.DatasetOutc omes1.GetXml()
'

End If
End Sub

Private Sub UpdateOutcomes( )
Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
Me.DataGridOutc omes.DataBind()
End Sub

Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles cmdAdd.Click

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

Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdAddOutcome.C lick
Dim dr As DatasetOutcomes .OutcomesRow

dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
dr.Item("Name") = Me.txtOutcome.T ext
dr.Item("Displa yOrder") = Me.DatasetOutco mes1.Outcomes.R ows.Count
'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
Me.DatasetOutco mes1.Outcomes.R ows.Count)

DatasetOutcomes 1.Outcomes.Rows .Add(dr)
Me.DataGridOutc omes.DataBind()

Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml

End Sub

End Class

Nov 17 '05 #1
12 2850
Most of the time, your code can follow this pattern:

Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
System.EventArg s) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeH ow()
myDataGrid.Data Source = myDataSet
myDataGrid.Data Member = "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***********@s urfcontrol.com
"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).

Thanks in advance,

James
Web Form:

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="cou rse_new.aspx.vb "
Inherits="_1137 InsetBookingSys tem.course_new" %>
<!-- #INCLUDE file="headerasp x.inc" -->
<!-- #INCLUDE file="tablehead er.inc" -->
<form id="FormNewCour se" method="post" runat="server">
<table cellSpacing="0" cols="3" cellPadding="0" width="100%" border="0">
<tr>
<td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
Font-Bold="True">Cou rse Title</asp:label></td>
<td><asp:textbo x id="txtCourseTi tle" runat="server"> </asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblCourseTu torList" runat="server"
Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
</tr>
<tr>
<td vAlign="top">&n bsp;</td>
<td><asp:textbo x id="txtCourseTu tor" runat="server"> </asp:textbox></td>
<td><asp:butt on id="cmdAdd" runat="server" Text="Add" BackColor="#F6C D7A" BorderStyle="So lid" BorderWidth="1p x"
Width="80px"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
TextMode="Multi Line"></asp:textbox></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblLearning Outcomes" runat="server"
Font-Bold="True">Lea rning Outcomes</asp:label></td>
</TD></tr>
<tr>
<td>&nbsp;</td>
<td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td>
<td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
BackColor="#F6C D7A" BorderStyle="So lid"
BorderWidth="1p x" Width="80px"
CausesValidatio n="False"></asp:button></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:datagr id id=DataGridOutc omes runat="server" GridLines="None "
AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
DatasetOutcomes 1 %>">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn>
<ItemTemplate >
<ul>
<li>
</li>
</ul>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Name " SortExpression= "Name"
HeaderText="Nam e"></asp:BoundColumn >
<asp:BoundColum n DataField="Disp layOrder"
SortExpression= "DisplayOrd er" HeaderText="Dis playOrder"></asp:BoundColumn >
<asp:ButtonColu mn Text="Delete"
ButtonType="Pus hButton"></asp:ButtonColum n>
<asp:ButtonColu mn Text="Edit"
ButtonType="Pus hButton"></asp:ButtonColum n>
</Columns>
</asp:datagrid></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colSpan="3"><as p:label id="lblOutcomes "
runat="server"> </asp:label></td>
</tr>
</table>
</form>
<!-- #INCLUDE file="tablefoot er.inc" -->
<!-- #INCLUDE file="footer.in c" -->
Code Bind:

Imports System
Imports System.IO
Imports System.Xml
Public Class course_new
Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.DatasetOutco mes1 = New _1137InsetBooki ngSystem.Datase tOutcomes
CType(Me.Datase tOutcomes1,
System.Componen tModel.ISupport Initialize).Beg inInit()
'
'DatasetOutcome s1
'
Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
Me.DatasetOutco mes1.Locale = New
System.Globaliz ation.CultureIn fo("en-GB")
CType(Me.Datase tOutcomes1,
System.Componen tModel.ISupport Initialize).End Init()

End Sub
Protected WithEvents lblCourseTitle As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtCourseTitle As System.Web.UI.W ebControls.Text Box Protected WithEvents txtCourseTutor As System.Web.UI.W ebControls.Text Box Protected WithEvents txtTutorList As System.Web.UI.W ebControls.Text Box
Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on
Protected WithEvents txtOutcome As System.Web.UI.W ebControls.Text Box
Protected WithEvents cmdAddOutcome As System.Web.UI.W ebControls.Butt on
Protected WithEvents lblCourseTutorL ist As
System.Web.UI.W ebControls.Labe l
Protected WithEvents lblLearningOutc omes As
System.Web.UI.W ebControls.Labe l
Protected WithEvents DataGridOutcome s As
System.Web.UI.W ebControls.Data Grid
Protected WithEvents DatasetOutcomes 1 As
_1137InsetBooki ngSystem.Datase tOutcomes
Protected WithEvents lblOutcomes As System.Web.UI.W ebControls.Labe l

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

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

#End Region
Public gstrTableTitle As String = "Create Course"
Public gstrTableAttrib s As String

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

If str.Length > 0 Then
MyStream = New StreamReader(st r)
Me.DatasetOutco mes1.ReadXml(My Stream)

End If

'Me.DatasetOutc omes1.GetXml()
'

End If
End Sub

Private Sub UpdateOutcomes( )
Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
Me.DataGridOutc omes.DataBind()
End Sub

Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles cmdAdd.Click

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

Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdAddOutcome.C lick
Dim dr As DatasetOutcomes .OutcomesRow

dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
dr.Item("Name") = Me.txtOutcome.T ext
dr.Item("Displa yOrder") = Me.DatasetOutco mes1.Outcomes.R ows.Count
'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
Me.DatasetOutco mes1.Outcomes.R ows.Count)

DatasetOutcomes 1.Outcomes.Rows .Add(dr)
Me.DataGridOutc omes.DataBind()

Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml

End Sub

End Class

Nov 17 '05 #2
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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd"
xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

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

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

If xmlFrag.Length > 0 Then

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

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

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag,
XmlNodeType.Ele ment, context)

Me.DatasetCours e.ReadXml(xmlTR )

End If
End If
End Sub
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeH ow()
myDataGrid.Data Source = myDataSet
myDataGrid.Data Member = "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***********@s urfcontrol.com
"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
>
> Thanks in advance,
>
> James
>
>
> Web Form:
>
> <%@ Page Language="vb" AutoEventWireup ="false"
> Codebehind="cou rse_new.aspx.vb "
> Inherits="_1137 InsetBookingSys tem.course_new" %>
> <!-- #INCLUDE file="headerasp x.inc" -->
> <!-- #INCLUDE file="tablehead er.inc" -->
> <form id="FormNewCour se" method="post" runat="server">
> <table cellSpacing="0" cols="3" cellPadding="0" width="100%"

border="0">
> <tr>
> <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
> Font-Bold="True">Cou rse Title</asp:label></td>
> <td><asp:textbo x id="txtCourseTi tle"

runat="server"> </asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblCourseTu torList" runat="server"
> Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> </tr>
> <tr>
> <td vAlign="top">&n bsp;</td>
> <td><asp:textbo x id="txtCourseTu tor"

runat="server"> </asp:textbox></td>
> <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
BackColor="#F6C D7A"
> BorderStyle="So lid" BorderWidth="1p x"
> Width="80px"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> TextMode="Multi Line"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblLearning Outcomes" runat="server" > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> </TD></tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td> > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> BackColor="#F6C D7A" BorderStyle="So lid"
> BorderWidth="1p x" Width="80px"
> CausesValidatio n="False"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:datagr id id=DataGridOutc omes runat="server" GridLines="None " > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
> DatasetOutcomes 1 %>">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> <Columns>
> <asp:TemplateCo lumn>
> <ItemTemplate >
> <ul>
> <li>
> </li>
> </ul>
> </ItemTemplate>
> </asp:TemplateCol umn>
> <asp:BoundColum n DataField="Name " SortExpression= "Name"
> HeaderText="Nam e"></asp:BoundColumn >
> <asp:BoundColum n DataField="Disp layOrder"
> SortExpression= "DisplayOrd er"

HeaderText="Dis playOrder"></asp:BoundColumn >
> <asp:ButtonColu mn Text="Delete"
> ButtonType="Pus hButton"></asp:ButtonColum n>
> <asp:ButtonColu mn Text="Edit"
> ButtonType="Pus hButton"></asp:ButtonColum n>
> </Columns>
> </asp:datagrid></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblOutcomes "
> runat="server"> </asp:label></td>
> </tr>
> </table>
> </form>
> <!-- #INCLUDE file="tablefoot er.inc" -->
> <!-- #INCLUDE file="footer.in c" -->
>
>
> Code Bind:
>
> Imports System
> Imports System.IO
> Imports System.Xml
>
>
> Public Class course_new
> Inherits System.Web.UI.P age
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> InitializeCompo nent()
> Me.DatasetOutco mes1 = New

_1137InsetBooki ngSystem.Datase tOutcomes
> CType(Me.Datase tOutcomes1,
> System.Componen tModel.ISupport Initialize).Beg inInit()
> '
> 'DatasetOutcome s1
> '
> Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> Me.DatasetOutco mes1.Locale = New
> System.Globaliz ation.CultureIn fo("en-GB")
> CType(Me.Datase tOutcomes1,
> System.Componen tModel.ISupport Initialize).End Init()
>
> End Sub
> Protected WithEvents lblCourseTitle As

System.Web.UI.W ebControls.Labe l
> Protected WithEvents txtCourseTitle As
System.Web.UI.W ebControls.Text Box
> Protected WithEvents txtCourseTutor As
System.Web.UI.W ebControls.Text Box
> Protected WithEvents txtTutorList As

System.Web.UI.W ebControls.Text Box
> Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on
> Protected WithEvents txtOutcome As System.Web.UI.W ebControls.Text Box > Protected WithEvents cmdAddOutcome As

System.Web.UI.W ebControls.Butt on
> Protected WithEvents lblCourseTutorL ist As
> System.Web.UI.W ebControls.Labe l
> Protected WithEvents lblLearningOutc omes As
> System.Web.UI.W ebControls.Labe l
> Protected WithEvents DataGridOutcome s As
> System.Web.UI.W ebControls.Data Grid
> Protected WithEvents DatasetOutcomes 1 As
> _1137InsetBooki ngSystem.Datase tOutcomes
> Protected WithEvents lblOutcomes As System.Web.UI.W ebControls.Labe l >
> 'NOTE: The following placeholder declaration is required by the Web Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceho lderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer > 'Do not modify it using the code editor.
> InitializeCompo nent()
> End Sub
>
> #End Region
> Public gstrTableTitle As String = "Create Course"
> Public gstrTableAttrib s As String
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
> Me.DataGridOutc omes.DataBind()
> Else
> Dim str As String = Me.lblOutcomes. Text
> Dim MyStream As StreamReader
>
> If str.Length > 0 Then
> MyStream = New StreamReader(st r)
> Me.DatasetOutco mes1.ReadXml(My Stream)
>
> End If
>
>
>
> 'Me.DatasetOutc omes1.GetXml()
> '
>
> End If
> End Sub
>
> Private Sub UpdateOutcomes( )
> Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> Me.DataGridOutc omes.DataBind()
> End Sub
>
> Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As > System.EventArg s) Handles cmdAdd.Click
>
> If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) < 1 Then > If Me.txtTutorList .Text.Length > 0 Then
> Me.txtTutorList .Text = Me.txtTutorList .Text & ";" &

vbCrLf
&
> Me.txtCourseTut or.Text
> Else
> Me.txtTutorList .Text = Me.txtCourseTut or.Text
> End If
> End If
> End Sub
>
> Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object,

ByVal
e
> As System.EventArg s) Handles cmdAddOutcome.C lick
> Dim dr As DatasetOutcomes .OutcomesRow
>
> dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> dr.Item("Name") = Me.txtOutcome.T ext
> dr.Item("Displa yOrder") =

Me.DatasetOutco mes1.Outcomes.R ows.Count
> 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> Me.DatasetOutco mes1.Outcomes.R ows.Count)
>
> DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> Me.DataGridOutc omes.DataBind()
>
> Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
>
> End Sub
>
> End Class
>
>
>



Nov 17 '05 #3
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("Datase tCourse")
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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd"
xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

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

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

If xmlFrag.Length > 0 Then

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

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

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag, XmlNodeType.Ele ment, context)

Me.DatasetCours e.ReadXml(xmlTR )

End If
End If
End Sub
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> If Not Page.IsPostBack Then
> myDataSet = GetDataSetSomeH ow()
> myDataGrid.Data Source = myDataSet
> myDataGrid.Data Member = "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***********@s urfcontrol.com
>
>
> "James Norton-Jones" <ja************ ****@stopford.c om> wrote in message > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> >
> > Thanks in advance,
> >
> > James
> >
> >
> > Web Form:
> >
> > <%@ Page Language="vb" AutoEventWireup ="false"
> > Codebehind="cou rse_new.aspx.vb "
> > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > <!-- #INCLUDE file="headerasp x.inc" -->
> > <!-- #INCLUDE file="tablehead er.inc" -->
> > <form id="FormNewCour se" method="post" runat="server">
> > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
border="0">
> > <tr>
> > <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
> > Font-Bold="True">Cou rse Title</asp:label></td>
> > <td><asp:textbo x id="txtCourseTi tle"
runat="server"> </asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblCourseTu torList"
runat="server" > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > </tr>
> > <tr>
> > <td vAlign="top">&n bsp;</td>
> > <td><asp:textbo x id="txtCourseTu tor"
runat="server"> </asp:textbox></td>
> > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> BackColor="#F6C D7A"
> > BorderStyle="So lid" BorderWidth="1p x"
> > Width="80px"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > TextMode="Multi Line"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblLearning Outcomes"
runat="server" > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > </TD></tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td> > > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> > BackColor="#F6C D7A" BorderStyle="So lid"
> > BorderWidth="1p x" Width="80px"
> > CausesValidatio n="False"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:datagr id id=DataGridOutc omes runat="server"

GridLines="None "
> > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
> > DatasetOutcomes 1 %>">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > <Columns>
> > <asp:TemplateCo lumn>
> > <ItemTemplate >
> > <ul>
> > <li>
> > </li>
> > </ul>
> > </ItemTemplate>
> > </asp:TemplateCol umn>
> > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > HeaderText="Nam e"></asp:BoundColumn >
> > <asp:BoundColum n DataField="Disp layOrder"
> > SortExpression= "DisplayOrd er"
HeaderText="Dis playOrder"></asp:BoundColumn >
> > <asp:ButtonColu mn Text="Delete"
> > ButtonType="Pus hButton"></asp:ButtonColum n>
> > <asp:ButtonColu mn Text="Edit"
> > ButtonType="Pus hButton"></asp:ButtonColum n>
> > </Columns>
> > </asp:datagrid></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblOutcomes "
> > runat="server"> </asp:label></td>
> > </tr>
> > </table>
> > </form>
> > <!-- #INCLUDE file="tablefoot er.inc" -->
> > <!-- #INCLUDE file="footer.in c" -->
> >
> >
> > Code Bind:
> >
> > Imports System
> > Imports System.IO
> > Imports System.Xml
> >
> >
> > Public Class course_new
> > Inherits System.Web.UI.P age
> >
> > #Region " Web Form Designer Generated Code "
> >
> > 'This call is required by the Web Form Designer.
> > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > InitializeCompo nent()
> > Me.DatasetOutco mes1 = New
_1137InsetBooki ngSystem.Datase tOutcomes
> > CType(Me.Datase tOutcomes1,
> > System.Componen tModel.ISupport Initialize).Beg inInit()
> > '
> > 'DatasetOutcome s1
> > '
> > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > Me.DatasetOutco mes1.Locale = New
> > System.Globaliz ation.CultureIn fo("en-GB")
> > CType(Me.Datase tOutcomes1,
> > System.Componen tModel.ISupport Initialize).End Init()
> >
> > End Sub
> > Protected WithEvents lblCourseTitle As
System.Web.UI.W ebControls.Labe l
> > Protected WithEvents txtCourseTitle As
> System.Web.UI.W ebControls.Text Box
> > Protected WithEvents txtCourseTutor As
> System.Web.UI.W ebControls.Text Box
> > Protected WithEvents txtTutorList As
System.Web.UI.W ebControls.Text Box
> > Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on > > Protected WithEvents txtOutcome As

System.Web.UI.W ebControls.Text Box
> > Protected WithEvents cmdAddOutcome As
System.Web.UI.W ebControls.Butt on
> > Protected WithEvents lblCourseTutorL ist As
> > System.Web.UI.W ebControls.Labe l
> > Protected WithEvents lblLearningOutc omes As
> > System.Web.UI.W ebControls.Labe l
> > Protected WithEvents DataGridOutcome s As
> > System.Web.UI.W ebControls.Data Grid
> > Protected WithEvents DatasetOutcomes 1 As
> > _1137InsetBooki ngSystem.Datase tOutcomes
> > Protected WithEvents lblOutcomes As

System.Web.UI.W ebControls.Labe l
> >
> > 'NOTE: The following placeholder declaration is required by the Web
> Form
> > Designer.
> > 'Do not delete or move it.
> > Private designerPlaceho lderDeclaration As System.Object
> >
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As > > System.EventArg s) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form

Designer
> > 'Do not modify it using the code editor.
> > InitializeCompo nent()
> > End Sub
> >
> > #End Region
> > Public gstrTableTitle As String = "Create Course"
> > Public gstrTableAttrib s As String
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArg s) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> > Me.DataGridOutc omes.DataBind()
> > Else
> > Dim str As String = Me.lblOutcomes. Text
> > Dim MyStream As StreamReader
> >
> > If str.Length > 0 Then
> > MyStream = New StreamReader(st r)
> > Me.DatasetOutco mes1.ReadXml(My Stream)
> >
> > End If
> >
> >
> >
> > 'Me.DatasetOutc omes1.GetXml()
> > '
> >
> > End If
> > End Sub
> >
> > Private Sub UpdateOutcomes( )
> > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > Me.DataGridOutc omes.DataBind()
> > End Sub
> >
> > Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As > > System.EventArg s) Handles cmdAdd.Click
> >
> > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) < 1

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

& vbCrLf
> &
> > Me.txtCourseTut or.Text
> > Else
> > Me.txtTutorList .Text = Me.txtCourseTut or.Text
> > End If
> > End If
> > End Sub
> >
> > Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object,

ByVal
e
> > As System.EventArg s) Handles cmdAddOutcome.C lick
> > Dim dr As DatasetOutcomes .OutcomesRow
> >
> > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > dr.Item("Name") = Me.txtOutcome.T ext
> > dr.Item("Displa yOrder") =
Me.DatasetOutco mes1.Outcomes.R ows.Count
> > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> >
> > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > Me.DataGridOutc omes.DataBind()
> >
> > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> >
> > End Sub
> >
> > End Class
> >
> >
> >
>
>



Nov 17 '05 #4
Session:

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

"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:uh******** ******@TK2MSFTN GP12.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("Datase tCourse") 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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd" xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message news:3f******** *************** @news.easynet.c o.uk...
> Managed to solve it using:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
>
> Me.DataGridOutc omes.DataBind()
> Else
> 'Create the XML fragment to be parsed.
> Dim xmlFrag As String = Me.lblOutcomes. Text
>
> If xmlFrag.Length > 0 Then
>
> 'Create the XmlNamespaceMan ager.
> Dim nt As NameTable = New NameTable
> Dim nsmgr As XmlNamespaceMan ager = New
> XmlNamespaceMan ager(nt)
>
> 'Create the XmlParserContex t.
> Dim context As XmlParserContex t = New
> XmlParserContex t(Nothing, nsmgr, Nothing, XmlSpace.None)
>
> 'Create the reader.
> Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag, > XmlNodeType.Ele ment, context)
>
> Me.DatasetCours e.ReadXml(xmlTR )
>
> End If
> End If
> End Sub
>
>
> "John Saunders" <jo***********@ surfcontrol.com > wrote in message
> news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> > If Not Page.IsPostBack Then
> > myDataSet = GetDataSetSomeH ow()
> > myDataGrid.Data Source = myDataSet
> > myDataGrid.Data Member = "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***********@s urfcontrol.com
> >
> >
> > "James Norton-Jones" <ja************ ****@stopford.c om> wrote in

message
> > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> > >
> > > Thanks in advance,
> > >
> > > James
> > >
> > >
> > > Web Form:
> > >
> > > <%@ Page Language="vb" AutoEventWireup ="false"
> > > Codebehind="cou rse_new.aspx.vb "
> > > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > > <!-- #INCLUDE file="headerasp x.inc" -->
> > > <!-- #INCLUDE file="tablehead er.inc" -->
> > > <form id="FormNewCour se" method="post" runat="server">
> > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> border="0">
> > > <tr>
> > > <td vAlign="top"><a sp:label id="lblCourseTi tle"
runat="server" > > > Font-Bold="True">Cou rse Title</asp:label></td>
> > > <td><asp:textbo x id="txtCourseTi tle"
> runat="server"> </asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblCourseTu torList"

runat="server" > > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > > </tr>
> > > <tr>
> > > <td vAlign="top">&n bsp;</td>
> > > <td><asp:textbo x id="txtCourseTu tor"
> runat="server"> </asp:textbox></td>
> > > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> > BackColor="#F6C D7A"
> > > BorderStyle="So lid" BorderWidth="1p x"
> > > Width="80px"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > > TextMode="Multi Line"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblLearning Outcomes"

runat="server"
> > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > > </TD></tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbo x id="txtOutcome "

runat="server"> </asp:textbox></td>
> > > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> > > BackColor="#F6C D7A" BorderStyle="So lid"
> > > BorderWidth="1p x" Width="80px"
> > > CausesValidatio n="False"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:datagr id id=DataGridOutc omes runat="server"
GridLines="None "
> > > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%# > > > DatasetOutcomes 1 %>">
> > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > <Columns>
> > > <asp:TemplateCo lumn>
> > > <ItemTemplate >
> > > <ul>
> > > <li>
> > > </li>
> > > </ul>
> > > </ItemTemplate>
> > > </asp:TemplateCol umn>
> > > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > > HeaderText="Nam e"></asp:BoundColumn >
> > > <asp:BoundColum n DataField="Disp layOrder"
> > > SortExpression= "DisplayOrd er"
> HeaderText="Dis playOrder"></asp:BoundColumn >
> > > <asp:ButtonColu mn Text="Delete"
> > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > <asp:ButtonColu mn Text="Edit"
> > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > </Columns>
> > > </asp:datagrid></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblOutcomes "
> > > runat="server"> </asp:label></td>
> > > </tr>
> > > </table>
> > > </form>
> > > <!-- #INCLUDE file="tablefoot er.inc" -->
> > > <!-- #INCLUDE file="footer.in c" -->
> > >
> > >
> > > Code Bind:
> > >
> > > Imports System
> > > Imports System.IO
> > > Imports System.Xml
> > >
> > >
> > > Public Class course_new
> > > Inherits System.Web.UI.P age
> > >
> > > #Region " Web Form Designer Generated Code "
> > >
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > > InitializeCompo nent()
> > > Me.DatasetOutco mes1 = New
> _1137InsetBooki ngSystem.Datase tOutcomes
> > > CType(Me.Datase tOutcomes1,
> > > System.Componen tModel.ISupport Initialize).Beg inInit()
> > > '
> > > 'DatasetOutcome s1
> > > '
> > > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > > Me.DatasetOutco mes1.Locale = New
> > > System.Globaliz ation.CultureIn fo("en-GB")
> > > CType(Me.Datase tOutcomes1,
> > > System.Componen tModel.ISupport Initialize).End Init()
> > >
> > > End Sub
> > > Protected WithEvents lblCourseTitle As
> System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents txtCourseTitle As
> > System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents txtCourseTutor As
> > System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents txtTutorList As
> System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on > > > Protected WithEvents txtOutcome As
System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents cmdAddOutcome As
> System.Web.UI.W ebControls.Butt on
> > > Protected WithEvents lblCourseTutorL ist As
> > > System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents lblLearningOutc omes As
> > > System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents DataGridOutcome s As
> > > System.Web.UI.W ebControls.Data Grid
> > > Protected WithEvents DatasetOutcomes 1 As
> > > _1137InsetBooki ngSystem.Datase tOutcomes
> > > Protected WithEvents lblOutcomes As
System.Web.UI.W ebControls.Labe l
> > >
> > > 'NOTE: The following placeholder declaration is required by the Web
> > Form
> > > Designer.
> > > 'Do not delete or move it.
> > > Private designerPlaceho lderDeclaration As System.Object
> > >
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > > > System.EventArg s) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
Designer
> > > 'Do not modify it using the code editor.
> > > InitializeCompo nent()
> > > End Sub
> > >
> > > #End Region
> > > Public gstrTableTitle As String = "Create Course"
> > > Public gstrTableAttrib s As String
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArg s) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > If Not Page.IsPostBack Then
> > > Me.DataGridOutc omes.DataBind()
> > > Else
> > > Dim str As String = Me.lblOutcomes. Text
> > > Dim MyStream As StreamReader
> > >
> > > If str.Length > 0 Then
> > > MyStream = New StreamReader(st r)
> > > Me.DatasetOutco mes1.ReadXml(My Stream)
> > >
> > > End If
> > >
> > >
> > >
> > > 'Me.DatasetOutc omes1.GetXml()
> > > '
> > >
> > > End If
> > > End Sub
> > >
> > > Private Sub UpdateOutcomes( )
> > > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > > Me.DataGridOutc omes.DataBind()
> > > End Sub
> > >
> > > Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e
As
> > > System.EventArg s) Handles cmdAdd.Click
> > >
> > > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) <
1 Then
> > > If Me.txtTutorList .Text.Length > 0 Then
> > > Me.txtTutorList .Text = Me.txtTutorList .Text & ";"
& > vbCrLf
> > &
> > > Me.txtCourseTut or.Text
> > > Else
> > > Me.txtTutorList .Text = Me.txtCourseTut or.Text
> > > End If
> > > End If
> > > End Sub
> > >
> > > Private Sub cmdAddOutcome_C lick(ByVal sender As

System.Object, ByVal
> e
> > > As System.EventArg s) Handles cmdAddOutcome.C lick
> > > Dim dr As DatasetOutcomes .OutcomesRow
> > >
> > > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > > dr.Item("Name") = Me.txtOutcome.T ext
> > > dr.Item("Displa yOrder") =
> Me.DatasetOutco mes1.Outcomes.R ows.Count
> > > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> > >
> > > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > > Me.DataGridOutc omes.DataBind()
> > >
> > > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #5
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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd"
xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

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

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

If xmlFrag.Length > 0 Then

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

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

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag,
XmlNodeType.Ele ment, context)

Me.DatasetCours e.ReadXml(xmlTR )

End If
End If
End Sub
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
If Not Page.IsPostBack Then
myDataSet = GetDataSetSomeH ow()
myDataGrid.Data Source = myDataSet
myDataGrid.Data Member = "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***********@s urfcontrol.com
"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
>
> Thanks in advance,
>
> James
>
>
> Web Form:
>
> <%@ Page Language="vb" AutoEventWireup ="false"
> Codebehind="cou rse_new.aspx.vb "
> Inherits="_1137 InsetBookingSys tem.course_new" %>
> <!-- #INCLUDE file="headerasp x.inc" -->
> <!-- #INCLUDE file="tablehead er.inc" -->
> <form id="FormNewCour se" method="post" runat="server">
> <table cellSpacing="0" cols="3" cellPadding="0" width="100%"

border="0">
> <tr>
> <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
> Font-Bold="True">Cou rse Title</asp:label></td>
> <td><asp:textbo x id="txtCourseTi tle"

runat="server"> </asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblCourseTu torList" runat="server"
> Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> </tr>
> <tr>
> <td vAlign="top">&n bsp;</td>
> <td><asp:textbo x id="txtCourseTu tor"

runat="server"> </asp:textbox></td>
> <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
BackColor="#F6C D7A"
> BorderStyle="So lid" BorderWidth="1p x"
> Width="80px"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> TextMode="Multi Line"></asp:textbox></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblLearning Outcomes" runat="server" > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> </TD></tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td> > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> BackColor="#F6C D7A" BorderStyle="So lid"
> BorderWidth="1p x" Width="80px"
> CausesValidatio n="False"></asp:button></td>
> </tr>
> <tr>
> <td>&nbsp;</td>
> <td><asp:datagr id id=DataGridOutc omes runat="server" GridLines="None " > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
> DatasetOutcomes 1 %>">
> <HeaderStyle Font-Bold="True"></HeaderStyle>
> <Columns>
> <asp:TemplateCo lumn>
> <ItemTemplate >
> <ul>
> <li>
> </li>
> </ul>
> </ItemTemplate>
> </asp:TemplateCol umn>
> <asp:BoundColum n DataField="Name " SortExpression= "Name"
> HeaderText="Nam e"></asp:BoundColumn >
> <asp:BoundColum n DataField="Disp layOrder"
> SortExpression= "DisplayOrd er"

HeaderText="Dis playOrder"></asp:BoundColumn >
> <asp:ButtonColu mn Text="Delete"
> ButtonType="Pus hButton"></asp:ButtonColum n>
> <asp:ButtonColu mn Text="Edit"
> ButtonType="Pus hButton"></asp:ButtonColum n>
> </Columns>
> </asp:datagrid></td>
> <td>&nbsp;</td>
> </tr>
> <tr>
> <td colSpan="3"><as p:label id="lblOutcomes "
> runat="server"> </asp:label></td>
> </tr>
> </table>
> </form>
> <!-- #INCLUDE file="tablefoot er.inc" -->
> <!-- #INCLUDE file="footer.in c" -->
>
>
> Code Bind:
>
> Imports System
> Imports System.IO
> Imports System.Xml
>
>
> Public Class course_new
> Inherits System.Web.UI.P age
>
> #Region " Web Form Designer Generated Code "
>
> 'This call is required by the Web Form Designer.
> <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> InitializeCompo nent()
> Me.DatasetOutco mes1 = New

_1137InsetBooki ngSystem.Datase tOutcomes
> CType(Me.Datase tOutcomes1,
> System.Componen tModel.ISupport Initialize).Beg inInit()
> '
> 'DatasetOutcome s1
> '
> Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> Me.DatasetOutco mes1.Locale = New
> System.Globaliz ation.CultureIn fo("en-GB")
> CType(Me.Datase tOutcomes1,
> System.Componen tModel.ISupport Initialize).End Init()
>
> End Sub
> Protected WithEvents lblCourseTitle As

System.Web.UI.W ebControls.Labe l
> Protected WithEvents txtCourseTitle As
System.Web.UI.W ebControls.Text Box
> Protected WithEvents txtCourseTutor As
System.Web.UI.W ebControls.Text Box
> Protected WithEvents txtTutorList As

System.Web.UI.W ebControls.Text Box
> Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on
> Protected WithEvents txtOutcome As System.Web.UI.W ebControls.Text Box > Protected WithEvents cmdAddOutcome As

System.Web.UI.W ebControls.Butt on
> Protected WithEvents lblCourseTutorL ist As
> System.Web.UI.W ebControls.Labe l
> Protected WithEvents lblLearningOutc omes As
> System.Web.UI.W ebControls.Labe l
> Protected WithEvents DataGridOutcome s As
> System.Web.UI.W ebControls.Data Grid
> Protected WithEvents DatasetOutcomes 1 As
> _1137InsetBooki ngSystem.Datase tOutcomes
> Protected WithEvents lblOutcomes As System.Web.UI.W ebControls.Labe l >
> 'NOTE: The following placeholder declaration is required by the Web Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceho lderDeclaration As System.Object
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer > 'Do not modify it using the code editor.
> InitializeCompo nent()
> End Sub
>
> #End Region
> Public gstrTableTitle As String = "Create Course"
> Public gstrTableAttrib s As String
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
> Me.DataGridOutc omes.DataBind()
> Else
> Dim str As String = Me.lblOutcomes. Text
> Dim MyStream As StreamReader
>
> If str.Length > 0 Then
> MyStream = New StreamReader(st r)
> Me.DatasetOutco mes1.ReadXml(My Stream)
>
> End If
>
>
>
> 'Me.DatasetOutc omes1.GetXml()
> '
>
> End If
> End Sub
>
> Private Sub UpdateOutcomes( )
> Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> Me.DataGridOutc omes.DataBind()
> End Sub
>
> Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As > System.EventArg s) Handles cmdAdd.Click
>
> If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) < 1 Then > If Me.txtTutorList .Text.Length > 0 Then
> Me.txtTutorList .Text = Me.txtTutorList .Text & ";" &

vbCrLf
&
> Me.txtCourseTut or.Text
> Else
> Me.txtTutorList .Text = Me.txtCourseTut or.Text
> End If
> End If
> End Sub
>
> Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object,

ByVal
e
> As System.EventArg s) Handles cmdAddOutcome.C lick
> Dim dr As DatasetOutcomes .OutcomesRow
>
> dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> dr.Item("Name") = Me.txtOutcome.T ext
> dr.Item("Displa yOrder") =

Me.DatasetOutco mes1.Outcomes.R ows.Count
> 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> Me.DatasetOutco mes1.Outcomes.R ows.Count)
>
> DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> Me.DataGridOutc omes.DataBind()
>
> Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
>
> End Sub
>
> End Class
>
>
>



Nov 17 '05 #6
Runs on multiple servers - and no Sql Server database to store session state
in.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

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

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

"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:uh******** ******@TK2MSFTN GP12.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("Datase tCourse")
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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd" xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" /> <xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com
>
> "James Norton-Jones" <ja************ ****@stopford.c om> wrote in message > news:3f******** *************** @news.easynet.c o.uk...
> > Managed to solve it using:
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArg s) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> >
> > Me.DataGridOutc omes.DataBind()
> > Else
> > 'Create the XML fragment to be parsed.
> > Dim xmlFrag As String = Me.lblOutcomes. Text
> >
> > If xmlFrag.Length > 0 Then
> >
> > 'Create the XmlNamespaceMan ager.
> > Dim nt As NameTable = New NameTable
> > Dim nsmgr As XmlNamespaceMan ager = New
> > XmlNamespaceMan ager(nt)
> >
> > 'Create the XmlParserContex t.
> > Dim context As XmlParserContex t = New
> > XmlParserContex t(Nothing, nsmgr, Nothing, XmlSpace.None)
> >
> > 'Create the reader.
> > Dim xmlTR As XmlTextReader = New

XmlTextReader(x mlFrag,
> > XmlNodeType.Ele ment, context)
> >
> > Me.DatasetCours e.ReadXml(xmlTR )
> >
> > End If
> > End If
> > End Sub
> >
> >
> > "John Saunders" <jo***********@ surfcontrol.com > wrote in message
> > news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> > > If Not Page.IsPostBack Then
> > > myDataSet = GetDataSetSomeH ow()
> > > myDataGrid.Data Source = myDataSet
> > > myDataGrid.Data Member = "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***********@s urfcontrol.com
> > >
> > >
> > > "James Norton-Jones" <ja************ ****@stopford.c om> wrote in
message
> > > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> > > >
> > > > Thanks in advance,
> > > >
> > > > James
> > > >
> > > >
> > > > Web Form:
> > > >
> > > > <%@ Page Language="vb" AutoEventWireup ="false"
> > > > Codebehind="cou rse_new.aspx.vb "
> > > > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > > > <!-- #INCLUDE file="headerasp x.inc" -->
> > > > <!-- #INCLUDE file="tablehead er.inc" -->
> > > > <form id="FormNewCour se" method="post" runat="server">
> > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> > border="0">
> > > > <tr>
> > > > <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server" > > > > Font-Bold="True">Cou rse Title</asp:label></td>
> > > > <td><asp:textbo x id="txtCourseTi tle"
> > runat="server"> </asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblCourseTu torList"

runat="server"
> > > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > > > </tr>
> > > > <tr>
> > > > <td vAlign="top">&n bsp;</td>
> > > > <td><asp:textbo x id="txtCourseTu tor"
> > runat="server"> </asp:textbox></td>
> > > > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> > > BackColor="#F6C D7A"
> > > > BorderStyle="So lid" BorderWidth="1p x"
> > > > Width="80px"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > > > TextMode="Multi Line"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblLearning Outcomes"
runat="server"
> > > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > > > </TD></tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbo x id="txtOutcome "
runat="server"> </asp:textbox></td>
> > > > <td><asp:butt on id="cmdAddOutco me" runat="server"
Text="Add" > > > > BackColor="#F6C D7A" BorderStyle="So lid"
> > > > BorderWidth="1p x" Width="80px"
> > > > CausesValidatio n="False"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:datagr id id=DataGridOutc omes runat="server"
> GridLines="None "
> > > > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%# > > > > DatasetOutcomes 1 %>">
> > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > <Columns>
> > > > <asp:TemplateCo lumn>
> > > > <ItemTemplate >
> > > > <ul>
> > > > <li>
> > > > </li>
> > > > </ul>
> > > > </ItemTemplate>
> > > > </asp:TemplateCol umn>
> > > > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > > > HeaderText="Nam e"></asp:BoundColumn >
> > > > <asp:BoundColum n DataField="Disp layOrder"
> > > > SortExpression= "DisplayOrd er"
> > HeaderText="Dis playOrder"></asp:BoundColumn >
> > > > <asp:ButtonColu mn Text="Delete"
> > > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > > <asp:ButtonColu mn Text="Edit"
> > > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > > </Columns>
> > > > </asp:datagrid></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblOutcomes "
> > > > runat="server"> </asp:label></td>
> > > > </tr>
> > > > </table>
> > > > </form>
> > > > <!-- #INCLUDE file="tablefoot er.inc" -->
> > > > <!-- #INCLUDE file="footer.in c" -->
> > > >
> > > >
> > > > Code Bind:
> > > >
> > > > Imports System
> > > > Imports System.IO
> > > > Imports System.Xml
> > > >
> > > >
> > > > Public Class course_new
> > > > Inherits System.Web.UI.P age
> > > >
> > > > #Region " Web Form Designer Generated Code "
> > > >
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > > > InitializeCompo nent()
> > > > Me.DatasetOutco mes1 = New
> > _1137InsetBooki ngSystem.Datase tOutcomes
> > > > CType(Me.Datase tOutcomes1,
> > > > System.Componen tModel.ISupport Initialize).Beg inInit()
> > > > '
> > > > 'DatasetOutcome s1
> > > > '
> > > > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > > > Me.DatasetOutco mes1.Locale = New
> > > > System.Globaliz ation.CultureIn fo("en-GB")
> > > > CType(Me.Datase tOutcomes1,
> > > > System.Componen tModel.ISupport Initialize).End Init()
> > > >
> > > > End Sub
> > > > Protected WithEvents lblCourseTitle As
> > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents txtCourseTitle As
> > > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents txtCourseTutor As
> > > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents txtTutorList As
> > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents cmdAdd As

System.Web.UI.W ebControls.Butt on
> > > > Protected WithEvents txtOutcome As
> System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents cmdAddOutcome As
> > System.Web.UI.W ebControls.Butt on
> > > > Protected WithEvents lblCourseTutorL ist As
> > > > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents lblLearningOutc omes As
> > > > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents DataGridOutcome s As
> > > > System.Web.UI.W ebControls.Data Grid
> > > > Protected WithEvents DatasetOutcomes 1 As
> > > > _1137InsetBooki ngSystem.Datase tOutcomes
> > > > Protected WithEvents lblOutcomes As
> System.Web.UI.W ebControls.Labe l
> > > >
> > > > 'NOTE: The following placeholder declaration is required
by the
> Web
> > > Form
> > > > Designer.
> > > > 'Do not delete or move it.
> > > > Private designerPlaceho lderDeclaration As System.Object
> > > >
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArg s) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeCompo nent()
> > > > End Sub
> > > >
> > > > #End Region
> > > > Public gstrTableTitle As String = "Create Course"
> > > > Public gstrTableAttrib s As String
> > > >
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArg s) Handles MyBase.Load
> > > > 'Put user code to initialize the page here
> > > > If Not Page.IsPostBack Then
> > > > Me.DataGridOutc omes.DataBind()
> > > > Else
> > > > Dim str As String = Me.lblOutcomes. Text
> > > > Dim MyStream As StreamReader
> > > >
> > > > If str.Length > 0 Then
> > > > MyStream = New StreamReader(st r)
> > > > Me.DatasetOutco mes1.ReadXml(My Stream)
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > 'Me.DatasetOutc omes1.GetXml()
> > > > '
> > > >
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub UpdateOutcomes( )
> > > > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > > > Me.DataGridOutc omes.DataBind()
> > > > End Sub
> > > >
> > > > Private Sub cmdAdd_Click(By Val sender As System.Object,

ByVal
e
As
> > > > System.EventArg s) Handles cmdAdd.Click
> > > >
> > > > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text)

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

System.Object, > ByVal
> > e
> > > > As System.EventArg s) Handles cmdAddOutcome.C lick
> > > > Dim dr As DatasetOutcomes .OutcomesRow
> > > >
> > > > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > > > dr.Item("Name") = Me.txtOutcome.T ext
> > > > dr.Item("Displa yOrder") =
> > Me.DatasetOutco mes1.Outcomes.R ows.Count
> > > > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > > > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> > > >
> > > > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > > > Me.DataGridOutc omes.DataBind()
> > > >
> > > > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> > > >
> > > > End Sub
> > > >
> > > > End Class
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #7
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("Datase tCourse")
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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd"
xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

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

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

If xmlFrag.Length > 0 Then

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

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

'Create the reader.
Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag, XmlNodeType.Ele ment, context)

Me.DatasetCours e.ReadXml(xmlTR )

End If
End If
End Sub
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> If Not Page.IsPostBack Then
> myDataSet = GetDataSetSomeH ow()
> myDataGrid.Data Source = myDataSet
> myDataGrid.Data Member = "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***********@s urfcontrol.com
>
>
> "James Norton-Jones" <ja************ ****@stopford.c om> wrote in message > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> >
> > Thanks in advance,
> >
> > James
> >
> >
> > Web Form:
> >
> > <%@ Page Language="vb" AutoEventWireup ="false"
> > Codebehind="cou rse_new.aspx.vb "
> > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > <!-- #INCLUDE file="headerasp x.inc" -->
> > <!-- #INCLUDE file="tablehead er.inc" -->
> > <form id="FormNewCour se" method="post" runat="server">
> > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
border="0">
> > <tr>
> > <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server"
> > Font-Bold="True">Cou rse Title</asp:label></td>
> > <td><asp:textbo x id="txtCourseTi tle"
runat="server"> </asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblCourseTu torList"
runat="server" > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > </tr>
> > <tr>
> > <td vAlign="top">&n bsp;</td>
> > <td><asp:textbo x id="txtCourseTu tor"
runat="server"> </asp:textbox></td>
> > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> BackColor="#F6C D7A"
> > BorderStyle="So lid" BorderWidth="1p x"
> > Width="80px"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > TextMode="Multi Line"></asp:textbox></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblLearning Outcomes"
runat="server" > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > </TD></tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:textbo x id="txtOutcome " runat="server"> </asp:textbox></td> > > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> > BackColor="#F6C D7A" BorderStyle="So lid"
> > BorderWidth="1p x" Width="80px"
> > CausesValidatio n="False"></asp:button></td>
> > </tr>
> > <tr>
> > <td>&nbsp;</td>
> > <td><asp:datagr id id=DataGridOutc omes runat="server"

GridLines="None "
> > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%#
> > DatasetOutcomes 1 %>">
> > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > <Columns>
> > <asp:TemplateCo lumn>
> > <ItemTemplate >
> > <ul>
> > <li>
> > </li>
> > </ul>
> > </ItemTemplate>
> > </asp:TemplateCol umn>
> > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > HeaderText="Nam e"></asp:BoundColumn >
> > <asp:BoundColum n DataField="Disp layOrder"
> > SortExpression= "DisplayOrd er"
HeaderText="Dis playOrder"></asp:BoundColumn >
> > <asp:ButtonColu mn Text="Delete"
> > ButtonType="Pus hButton"></asp:ButtonColum n>
> > <asp:ButtonColu mn Text="Edit"
> > ButtonType="Pus hButton"></asp:ButtonColum n>
> > </Columns>
> > </asp:datagrid></td>
> > <td>&nbsp;</td>
> > </tr>
> > <tr>
> > <td colSpan="3"><as p:label id="lblOutcomes "
> > runat="server"> </asp:label></td>
> > </tr>
> > </table>
> > </form>
> > <!-- #INCLUDE file="tablefoot er.inc" -->
> > <!-- #INCLUDE file="footer.in c" -->
> >
> >
> > Code Bind:
> >
> > Imports System
> > Imports System.IO
> > Imports System.Xml
> >
> >
> > Public Class course_new
> > Inherits System.Web.UI.P age
> >
> > #Region " Web Form Designer Generated Code "
> >
> > 'This call is required by the Web Form Designer.
> > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > InitializeCompo nent()
> > Me.DatasetOutco mes1 = New
_1137InsetBooki ngSystem.Datase tOutcomes
> > CType(Me.Datase tOutcomes1,
> > System.Componen tModel.ISupport Initialize).Beg inInit()
> > '
> > 'DatasetOutcome s1
> > '
> > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > Me.DatasetOutco mes1.Locale = New
> > System.Globaliz ation.CultureIn fo("en-GB")
> > CType(Me.Datase tOutcomes1,
> > System.Componen tModel.ISupport Initialize).End Init()
> >
> > End Sub
> > Protected WithEvents lblCourseTitle As
System.Web.UI.W ebControls.Labe l
> > Protected WithEvents txtCourseTitle As
> System.Web.UI.W ebControls.Text Box
> > Protected WithEvents txtCourseTutor As
> System.Web.UI.W ebControls.Text Box
> > Protected WithEvents txtTutorList As
System.Web.UI.W ebControls.Text Box
> > Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on > > Protected WithEvents txtOutcome As

System.Web.UI.W ebControls.Text Box
> > Protected WithEvents cmdAddOutcome As
System.Web.UI.W ebControls.Butt on
> > Protected WithEvents lblCourseTutorL ist As
> > System.Web.UI.W ebControls.Labe l
> > Protected WithEvents lblLearningOutc omes As
> > System.Web.UI.W ebControls.Labe l
> > Protected WithEvents DataGridOutcome s As
> > System.Web.UI.W ebControls.Data Grid
> > Protected WithEvents DatasetOutcomes 1 As
> > _1137InsetBooki ngSystem.Datase tOutcomes
> > Protected WithEvents lblOutcomes As

System.Web.UI.W ebControls.Labe l
> >
> > 'NOTE: The following placeholder declaration is required by the Web
> Form
> > Designer.
> > 'Do not delete or move it.
> > Private designerPlaceho lderDeclaration As System.Object
> >
> > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
As > > System.EventArg s) Handles MyBase.Init
> > 'CODEGEN: This method call is required by the Web Form

Designer
> > 'Do not modify it using the code editor.
> > InitializeCompo nent()
> > End Sub
> >
> > #End Region
> > Public gstrTableTitle As String = "Create Course"
> > Public gstrTableAttrib s As String
> >
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArg s) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> > Me.DataGridOutc omes.DataBind()
> > Else
> > Dim str As String = Me.lblOutcomes. Text
> > Dim MyStream As StreamReader
> >
> > If str.Length > 0 Then
> > MyStream = New StreamReader(st r)
> > Me.DatasetOutco mes1.ReadXml(My Stream)
> >
> > End If
> >
> >
> >
> > 'Me.DatasetOutc omes1.GetXml()
> > '
> >
> > End If
> > End Sub
> >
> > Private Sub UpdateOutcomes( )
> > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > Me.DataGridOutc omes.DataBind()
> > End Sub
> >
> > Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e As > > System.EventArg s) Handles cmdAdd.Click
> >
> > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) < 1

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

& vbCrLf
> &
> > Me.txtCourseTut or.Text
> > Else
> > Me.txtTutorList .Text = Me.txtCourseTut or.Text
> > End If
> > End If
> > End Sub
> >
> > Private Sub cmdAddOutcome_C lick(ByVal sender As System.Object,

ByVal
e
> > As System.EventArg s) Handles cmdAddOutcome.C lick
> > Dim dr As DatasetOutcomes .OutcomesRow
> >
> > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > dr.Item("Name") = Me.txtOutcome.T ext
> > dr.Item("Displa yOrder") =
Me.DatasetOutco mes1.Outcomes.R ows.Count
> > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> >
> > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > Me.DataGridOutc omes.DataBind()
> >
> > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> >
> > End Sub
> >
> > End Class
> >
> >
> >
>
>



Nov 17 '05 #8
Session:

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

"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:uh******** ******@TK2MSFTN GP12.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("Datase tCourse") 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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd" xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" />
<xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message news:3f******** *************** @news.easynet.c o.uk...
> Managed to solve it using:
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> 'Put user code to initialize the page here
> If Not Page.IsPostBack Then
>
> Me.DataGridOutc omes.DataBind()
> Else
> 'Create the XML fragment to be parsed.
> Dim xmlFrag As String = Me.lblOutcomes. Text
>
> If xmlFrag.Length > 0 Then
>
> 'Create the XmlNamespaceMan ager.
> Dim nt As NameTable = New NameTable
> Dim nsmgr As XmlNamespaceMan ager = New
> XmlNamespaceMan ager(nt)
>
> 'Create the XmlParserContex t.
> Dim context As XmlParserContex t = New
> XmlParserContex t(Nothing, nsmgr, Nothing, XmlSpace.None)
>
> 'Create the reader.
> Dim xmlTR As XmlTextReader = New XmlTextReader(x mlFrag, > XmlNodeType.Ele ment, context)
>
> Me.DatasetCours e.ReadXml(xmlTR )
>
> End If
> End If
> End Sub
>
>
> "John Saunders" <jo***********@ surfcontrol.com > wrote in message
> news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> > If Not Page.IsPostBack Then
> > myDataSet = GetDataSetSomeH ow()
> > myDataGrid.Data Source = myDataSet
> > myDataGrid.Data Member = "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***********@s urfcontrol.com
> >
> >
> > "James Norton-Jones" <ja************ ****@stopford.c om> wrote in

message
> > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> > >
> > > Thanks in advance,
> > >
> > > James
> > >
> > >
> > > Web Form:
> > >
> > > <%@ Page Language="vb" AutoEventWireup ="false"
> > > Codebehind="cou rse_new.aspx.vb "
> > > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > > <!-- #INCLUDE file="headerasp x.inc" -->
> > > <!-- #INCLUDE file="tablehead er.inc" -->
> > > <form id="FormNewCour se" method="post" runat="server">
> > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> border="0">
> > > <tr>
> > > <td vAlign="top"><a sp:label id="lblCourseTi tle"
runat="server" > > > Font-Bold="True">Cou rse Title</asp:label></td>
> > > <td><asp:textbo x id="txtCourseTi tle"
> runat="server"> </asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblCourseTu torList"

runat="server" > > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > > </tr>
> > > <tr>
> > > <td vAlign="top">&n bsp;</td>
> > > <td><asp:textbo x id="txtCourseTu tor"
> runat="server"> </asp:textbox></td>
> > > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> > BackColor="#F6C D7A"
> > > BorderStyle="So lid" BorderWidth="1p x"
> > > Width="80px"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > > TextMode="Multi Line"></asp:textbox></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblLearning Outcomes"

runat="server"
> > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > > </TD></tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:textbo x id="txtOutcome "

runat="server"> </asp:textbox></td>
> > > <td><asp:butt on id="cmdAddOutco me" runat="server" Text="Add"
> > > BackColor="#F6C D7A" BorderStyle="So lid"
> > > BorderWidth="1p x" Width="80px"
> > > CausesValidatio n="False"></asp:button></td>
> > > </tr>
> > > <tr>
> > > <td>&nbsp;</td>
> > > <td><asp:datagr id id=DataGridOutc omes runat="server"
GridLines="None "
> > > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%# > > > DatasetOutcomes 1 %>">
> > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > <Columns>
> > > <asp:TemplateCo lumn>
> > > <ItemTemplate >
> > > <ul>
> > > <li>
> > > </li>
> > > </ul>
> > > </ItemTemplate>
> > > </asp:TemplateCol umn>
> > > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > > HeaderText="Nam e"></asp:BoundColumn >
> > > <asp:BoundColum n DataField="Disp layOrder"
> > > SortExpression= "DisplayOrd er"
> HeaderText="Dis playOrder"></asp:BoundColumn >
> > > <asp:ButtonColu mn Text="Delete"
> > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > <asp:ButtonColu mn Text="Edit"
> > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > </Columns>
> > > </asp:datagrid></td>
> > > <td>&nbsp;</td>
> > > </tr>
> > > <tr>
> > > <td colSpan="3"><as p:label id="lblOutcomes "
> > > runat="server"> </asp:label></td>
> > > </tr>
> > > </table>
> > > </form>
> > > <!-- #INCLUDE file="tablefoot er.inc" -->
> > > <!-- #INCLUDE file="footer.in c" -->
> > >
> > >
> > > Code Bind:
> > >
> > > Imports System
> > > Imports System.IO
> > > Imports System.Xml
> > >
> > >
> > > Public Class course_new
> > > Inherits System.Web.UI.P age
> > >
> > > #Region " Web Form Designer Generated Code "
> > >
> > > 'This call is required by the Web Form Designer.
> > > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > > InitializeCompo nent()
> > > Me.DatasetOutco mes1 = New
> _1137InsetBooki ngSystem.Datase tOutcomes
> > > CType(Me.Datase tOutcomes1,
> > > System.Componen tModel.ISupport Initialize).Beg inInit()
> > > '
> > > 'DatasetOutcome s1
> > > '
> > > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > > Me.DatasetOutco mes1.Locale = New
> > > System.Globaliz ation.CultureIn fo("en-GB")
> > > CType(Me.Datase tOutcomes1,
> > > System.Componen tModel.ISupport Initialize).End Init()
> > >
> > > End Sub
> > > Protected WithEvents lblCourseTitle As
> System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents txtCourseTitle As
> > System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents txtCourseTutor As
> > System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents txtTutorList As
> System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents cmdAdd As System.Web.UI.W ebControls.Butt on > > > Protected WithEvents txtOutcome As
System.Web.UI.W ebControls.Text Box
> > > Protected WithEvents cmdAddOutcome As
> System.Web.UI.W ebControls.Butt on
> > > Protected WithEvents lblCourseTutorL ist As
> > > System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents lblLearningOutc omes As
> > > System.Web.UI.W ebControls.Labe l
> > > Protected WithEvents DataGridOutcome s As
> > > System.Web.UI.W ebControls.Data Grid
> > > Protected WithEvents DatasetOutcomes 1 As
> > > _1137InsetBooki ngSystem.Datase tOutcomes
> > > Protected WithEvents lblOutcomes As
System.Web.UI.W ebControls.Labe l
> > >
> > > 'NOTE: The following placeholder declaration is required by the Web
> > Form
> > > Designer.
> > > 'Do not delete or move it.
> > > Private designerPlaceho lderDeclaration As System.Object
> > >
> > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As > > > System.EventArg s) Handles MyBase.Init
> > > 'CODEGEN: This method call is required by the Web Form
Designer
> > > 'Do not modify it using the code editor.
> > > InitializeCompo nent()
> > > End Sub
> > >
> > > #End Region
> > > Public gstrTableTitle As String = "Create Course"
> > > Public gstrTableAttrib s As String
> > >
> > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > > System.EventArg s) Handles MyBase.Load
> > > 'Put user code to initialize the page here
> > > If Not Page.IsPostBack Then
> > > Me.DataGridOutc omes.DataBind()
> > > Else
> > > Dim str As String = Me.lblOutcomes. Text
> > > Dim MyStream As StreamReader
> > >
> > > If str.Length > 0 Then
> > > MyStream = New StreamReader(st r)
> > > Me.DatasetOutco mes1.ReadXml(My Stream)
> > >
> > > End If
> > >
> > >
> > >
> > > 'Me.DatasetOutc omes1.GetXml()
> > > '
> > >
> > > End If
> > > End Sub
> > >
> > > Private Sub UpdateOutcomes( )
> > > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > > Me.DataGridOutc omes.DataBind()
> > > End Sub
> > >
> > > Private Sub cmdAdd_Click(By Val sender As System.Object, ByVal e
As
> > > System.EventArg s) Handles cmdAdd.Click
> > >
> > > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text) <
1 Then
> > > If Me.txtTutorList .Text.Length > 0 Then
> > > Me.txtTutorList .Text = Me.txtTutorList .Text & ";"
& > vbCrLf
> > &
> > > Me.txtCourseTut or.Text
> > > Else
> > > Me.txtTutorList .Text = Me.txtCourseTut or.Text
> > > End If
> > > End If
> > > End Sub
> > >
> > > Private Sub cmdAddOutcome_C lick(ByVal sender As

System.Object, ByVal
> e
> > > As System.EventArg s) Handles cmdAddOutcome.C lick
> > > Dim dr As DatasetOutcomes .OutcomesRow
> > >
> > > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > > dr.Item("Name") = Me.txtOutcome.T ext
> > > dr.Item("Displa yOrder") =
> Me.DatasetOutco mes1.Outcomes.R ows.Count
> > > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> > >
> > > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > > Me.DataGridOutc omes.DataBind()
> > >
> > > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> > >
> > > End Sub
> > >
> > > End Class
> > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #9
Runs on multiple servers - and no Sql Server database to store session state
in.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

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

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

"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:uh******** ******@TK2MSFTN GP12.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("Datase tCourse")
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***********@s urfcontrol.com

"James Norton-Jones" <ja************ ****@stopford.c om> wrote in message
news:3f******** *************** @news.easynet.c o.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="DatasetOutc omes"
targetNamespace ="http://tempuri.org/DatasetOutcomes .xsd"
elementFormDefa ult="qualified"
attributeFormDe fault="qualifie d"
xmlns="http://http://localhost/1137InsetBookin gSystem/DatasetOutcomes .xsd" xmlns:mstns="ht tp://tempuri.org/DatasetOutcomes .xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="DatasetOu tcomes" msdata:IsDataSe t="true">
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="Outcomes" >
<xs:complexType >
<xs:sequence>
<xs:element name="Descripti on" type="xs:string " minOccurs="0" /> <xs:element name="DisplayOr der" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="DatasetOu tcomesKey1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:Outcomes" />
<xs:field xpath="mstns:De scription" />
</xs:key>
</xs:element>
</xs:schema>
"John Saunders" <jo***********@ surfcontrol.com > wrote in message
news:u1******** ******@TK2MSFTN GP09.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***********@s urfcontrol.com
>
> "James Norton-Jones" <ja************ ****@stopford.c om> wrote in message > news:3f******** *************** @news.easynet.c o.uk...
> > Managed to solve it using:
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As > > System.EventArg s) Handles MyBase.Load
> > 'Put user code to initialize the page here
> > If Not Page.IsPostBack Then
> >
> > Me.DataGridOutc omes.DataBind()
> > Else
> > 'Create the XML fragment to be parsed.
> > Dim xmlFrag As String = Me.lblOutcomes. Text
> >
> > If xmlFrag.Length > 0 Then
> >
> > 'Create the XmlNamespaceMan ager.
> > Dim nt As NameTable = New NameTable
> > Dim nsmgr As XmlNamespaceMan ager = New
> > XmlNamespaceMan ager(nt)
> >
> > 'Create the XmlParserContex t.
> > Dim context As XmlParserContex t = New
> > XmlParserContex t(Nothing, nsmgr, Nothing, XmlSpace.None)
> >
> > 'Create the reader.
> > Dim xmlTR As XmlTextReader = New

XmlTextReader(x mlFrag,
> > XmlNodeType.Ele ment, context)
> >
> > Me.DatasetCours e.ReadXml(xmlTR )
> >
> > End If
> > End If
> > End Sub
> >
> >
> > "John Saunders" <jo***********@ surfcontrol.com > wrote in message
> > news:OP******** ******@TK2MSFTN GP09.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.EventArg s) Handles MyBase.Load
> > > If Not Page.IsPostBack Then
> > > myDataSet = GetDataSetSomeH ow()
> > > myDataGrid.Data Source = myDataSet
> > > myDataGrid.Data Member = "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***********@s urfcontrol.com
> > >
> > >
> > > "James Norton-Jones" <ja************ ****@stopford.c om> wrote in
message
> > > news:3f******** *************** @news.easynet.c o.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 DataSetOutcomes 1.ReadXML(MyStr eam).
> > > >
> > > > Thanks in advance,
> > > >
> > > > James
> > > >
> > > >
> > > > Web Form:
> > > >
> > > > <%@ Page Language="vb" AutoEventWireup ="false"
> > > > Codebehind="cou rse_new.aspx.vb "
> > > > Inherits="_1137 InsetBookingSys tem.course_new" %>
> > > > <!-- #INCLUDE file="headerasp x.inc" -->
> > > > <!-- #INCLUDE file="tablehead er.inc" -->
> > > > <form id="FormNewCour se" method="post" runat="server">
> > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
> > border="0">
> > > > <tr>
> > > > <td vAlign="top"><a sp:label id="lblCourseTi tle" runat="server" > > > > Font-Bold="True">Cou rse Title</asp:label></td>
> > > > <td><asp:textbo x id="txtCourseTi tle"
> > runat="server"> </asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblCourseTu torList"

runat="server"
> > > > Font-Bold="True">Cou rse Tutor(s)</asp:label></td>
> > > > </tr>
> > > > <tr>
> > > > <td vAlign="top">&n bsp;</td>
> > > > <td><asp:textbo x id="txtCourseTu tor"
> > runat="server"> </asp:textbox></td>
> > > > <td><asp:butt on id="cmdAdd" runat="server" Text="Add"
> > > BackColor="#F6C D7A"
> > > > BorderStyle="So lid" BorderWidth="1p x"
> > > > Width="80px"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbo x id="txtTutorLis t" runat="server" Rows="5"
> > > > TextMode="Multi Line"></asp:textbox></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblLearning Outcomes"
runat="server"
> > > > Font-Bold="True">Lea rning Outcomes</asp:label></td>
> > > > </TD></tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:textbo x id="txtOutcome "
runat="server"> </asp:textbox></td>
> > > > <td><asp:butt on id="cmdAddOutco me" runat="server"
Text="Add" > > > > BackColor="#F6C D7A" BorderStyle="So lid"
> > > > BorderWidth="1p x" Width="80px"
> > > > CausesValidatio n="False"></asp:button></td>
> > > > </tr>
> > > > <tr>
> > > > <td>&nbsp;</td>
> > > > <td><asp:datagr id id=DataGridOutc omes runat="server"
> GridLines="None "
> > > > AutoGenerateCol umns="False" DataMember="Out comes" DataSource="<%# > > > > DatasetOutcomes 1 %>">
> > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
> > > > <Columns>
> > > > <asp:TemplateCo lumn>
> > > > <ItemTemplate >
> > > > <ul>
> > > > <li>
> > > > </li>
> > > > </ul>
> > > > </ItemTemplate>
> > > > </asp:TemplateCol umn>
> > > > <asp:BoundColum n DataField="Name " SortExpression= "Name"
> > > > HeaderText="Nam e"></asp:BoundColumn >
> > > > <asp:BoundColum n DataField="Disp layOrder"
> > > > SortExpression= "DisplayOrd er"
> > HeaderText="Dis playOrder"></asp:BoundColumn >
> > > > <asp:ButtonColu mn Text="Delete"
> > > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > > <asp:ButtonColu mn Text="Edit"
> > > > ButtonType="Pus hButton"></asp:ButtonColum n>
> > > > </Columns>
> > > > </asp:datagrid></td>
> > > > <td>&nbsp;</td>
> > > > </tr>
> > > > <tr>
> > > > <td colSpan="3"><as p:label id="lblOutcomes "
> > > > runat="server"> </asp:label></td>
> > > > </tr>
> > > > </table>
> > > > </form>
> > > > <!-- #INCLUDE file="tablefoot er.inc" -->
> > > > <!-- #INCLUDE file="footer.in c" -->
> > > >
> > > >
> > > > Code Bind:
> > > >
> > > > Imports System
> > > > Imports System.IO
> > > > Imports System.Xml
> > > >
> > > >
> > > > Public Class course_new
> > > > Inherits System.Web.UI.P age
> > > >
> > > > #Region " Web Form Designer Generated Code "
> > > >
> > > > 'This call is required by the Web Form Designer.
> > > > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub
> > > > InitializeCompo nent()
> > > > Me.DatasetOutco mes1 = New
> > _1137InsetBooki ngSystem.Datase tOutcomes
> > > > CType(Me.Datase tOutcomes1,
> > > > System.Componen tModel.ISupport Initialize).Beg inInit()
> > > > '
> > > > 'DatasetOutcome s1
> > > > '
> > > > Me.DatasetOutco mes1.DataSetNam e = "DatasetOutcome s"
> > > > Me.DatasetOutco mes1.Locale = New
> > > > System.Globaliz ation.CultureIn fo("en-GB")
> > > > CType(Me.Datase tOutcomes1,
> > > > System.Componen tModel.ISupport Initialize).End Init()
> > > >
> > > > End Sub
> > > > Protected WithEvents lblCourseTitle As
> > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents txtCourseTitle As
> > > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents txtCourseTutor As
> > > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents txtTutorList As
> > System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents cmdAdd As

System.Web.UI.W ebControls.Butt on
> > > > Protected WithEvents txtOutcome As
> System.Web.UI.W ebControls.Text Box
> > > > Protected WithEvents cmdAddOutcome As
> > System.Web.UI.W ebControls.Butt on
> > > > Protected WithEvents lblCourseTutorL ist As
> > > > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents lblLearningOutc omes As
> > > > System.Web.UI.W ebControls.Labe l
> > > > Protected WithEvents DataGridOutcome s As
> > > > System.Web.UI.W ebControls.Data Grid
> > > > Protected WithEvents DatasetOutcomes 1 As
> > > > _1137InsetBooki ngSystem.Datase tOutcomes
> > > > Protected WithEvents lblOutcomes As
> System.Web.UI.W ebControls.Labe l
> > > >
> > > > 'NOTE: The following placeholder declaration is required
by the
> Web
> > > Form
> > > > Designer.
> > > > 'Do not delete or move it.
> > > > Private designerPlaceho lderDeclaration As System.Object
> > > >
> > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArg s) Handles MyBase.Init
> > > > 'CODEGEN: This method call is required by the Web Form
> Designer
> > > > 'Do not modify it using the code editor.
> > > > InitializeCompo nent()
> > > > End Sub
> > > >
> > > > #End Region
> > > > Public gstrTableTitle As String = "Create Course"
> > > > Public gstrTableAttrib s As String
> > > >
> > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As
> > > > System.EventArg s) Handles MyBase.Load
> > > > 'Put user code to initialize the page here
> > > > If Not Page.IsPostBack Then
> > > > Me.DataGridOutc omes.DataBind()
> > > > Else
> > > > Dim str As String = Me.lblOutcomes. Text
> > > > Dim MyStream As StreamReader
> > > >
> > > > If str.Length > 0 Then
> > > > MyStream = New StreamReader(st r)
> > > > Me.DatasetOutco mes1.ReadXml(My Stream)
> > > >
> > > > End If
> > > >
> > > >
> > > >
> > > > 'Me.DatasetOutc omes1.GetXml()
> > > > '
> > > >
> > > > End If
> > > > End Sub
> > > >
> > > > Private Sub UpdateOutcomes( )
> > > > Me.DataGridOutc omes.DataSource = Me.DatasetOutco mes1
> > > > Me.DataGridOutc omes.DataBind()
> > > > End Sub
> > > >
> > > > Private Sub cmdAdd_Click(By Val sender As System.Object,

ByVal
e
As
> > > > System.EventArg s) Handles cmdAdd.Click
> > > >
> > > > If InStr(Me.txtTut orList.Text, Me.txtCourseTut or.Text)

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

System.Object, > ByVal
> > e
> > > > As System.EventArg s) Handles cmdAddOutcome.C lick
> > > > Dim dr As DatasetOutcomes .OutcomesRow
> > > >
> > > > dr = Me.DatasetOutco mes1.Outcomes.N ewRow()
> > > > dr.Item("Name") = Me.txtOutcome.T ext
> > > > dr.Item("Displa yOrder") =
> > Me.DatasetOutco mes1.Outcomes.R ows.Count
> > > > 'DatasetOutcome s1.Outcomes.Row s.InsertAt(dr,
> > > > Me.DatasetOutco mes1.Outcomes.R ows.Count)
> > > >
> > > > DatasetOutcomes 1.Outcomes.Rows .Add(dr)
> > > > Me.DataGridOutc omes.DataBind()
> > > >
> > > > Me.lblOutcomes. Text = Me.DatasetOutco mes1.GetXml
> > > >
> > > > End Sub
> > > >
> > > > End Class
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10282
by: Hal Vaughan | last post by:
If I have a byte and I convert it to string (String sData = new String(byte bData), then convert it back (byte bData = sData.getBytes()), will all data be intact, or do Strings have problems with bytes that are not printable characters? I've tested this and it seems to work fine, but I want to make sure there isn't some condition or situation...
7
16391
by: Donovan | last post by:
I can't believe this is causing me as much difficulty as it is, but I have an Infragistics UltraTreeview control that I want to persist whatever the user has in the tree. It has a method SaveAsXml which puts the contents into a MemoryStream, which I convert to a string for persistance (I know Infragistics allows me to, but I can't store as a...
6
1163
by: GaryB | last post by:
I have an ASPX page and a vb codebehind file that takes as input a passed web datagrid as input. My page has a CrystalReportsViewer on it. My page produces a PDF report of the DataGrid that was passed. I want to package this functionality into a component so that a programmer can simply drop my control onto an aspx page, enter the name of...
33
3647
by: Jordan Tiona | last post by:
How can I make one of these? I'm trying to get my program to store a string into a variable, but it only stores one line. -- "No eye has seen, no ear has heard, no mind can conceive what God has prepared for those who love him" 1 Cor 2:9
17
2001
by: Christoph Scholtes | last post by:
Hi, I have two questions about the following code snippet. I am trying to read in a series of strings and save them to character arrays. Since I dont know how long my string is going to be (and I dont want to waste memory by allocating an array of 1000 for all the input strings) I allocate the memory myself according to the length of the...
3
6636
by: grawsha2000 | last post by:
Hi, I'm trying to convert this simple string into image: Dim bytes() as byte()=System.text.Encoding.ascii.GetBytes("123") Dim memStream as System.IO.MemoryStream Dim img as image memStream.Write(bytes,0.bytes.length)
13
2019
by: coosa | last post by:
Dear all, Using the conio implementation i wanted to create a dynamic string, whereby its size would be determined after each keyboard hit; in other words, i don't want to ask the user to specify the the size, but rather keep him/her typing and after each keyboard hit, the function getch() determines whether he/she entered the ENTER key to...
111
19952
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- http://www.riscossione.info/
0
1299
by: Jack | last post by:
Hi, I do a webrequest and it returns some text data in a stream. I want to put this tyext data into a string. I've got it working just fine, but I have to put the text data into into a fixed-size buffer BEFORE I put it into a string (ConstBufferByteSize=1000000). This fixed size buffer wastes space. Is it possible to somehow assign it...
0
7565
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5130
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3520
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1097
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
804
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.