473,836 Members | 1,455 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 2897
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
10316
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 I'm not aware of that could cause problems. I'm doing this because it's easier to do some of my...
7
16400
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 file for various reasons, so it's not a valid alternative). I'm using this code to put into a string...
6
1172
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 a datagrid on that page to enable print functionality for that grid. Going through some books on...
33
3686
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
2034
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 string. char *inputData; char line;
3
6666
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
2045
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 end the process; otherwise, increases the dynamic size or also decreases it if the back key was...
111
20095
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
1316
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 straight to a string, or somehow do this 'dynamically' ?
0
9673
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9388
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7795
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6984
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5653
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5829
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4463
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.