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

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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 DataSetOutcomes1.ReadXML(MyStream).

    Thanks in advance,

    James


    Web Form:

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


    Code Bind:

    Imports System
    Imports System.IO
    Imports System.Xml


    Public Class course_new
    Inherits System.Web.UI.Page

    #Region " Web Form Designer Generated Code "

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

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

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

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

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

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

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

    End If



    'Me.DatasetOutcomes1.GetXml()
    '

    End If
    End Sub

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

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

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

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

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

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

    Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml

    End Sub

    End Class



    James Norton-Jones Guest

  2. Similar Questions and Discussions

    1. Putting an image in the footer of a datagrid.
      Is there anyway to put an image in the footer of a bound column in a datagrid ? TIA Jeffrey.
    2. putting a DataGrid Item in a web user control into Editmode from the parent page.
      Hello I am trying to put a Datagrid which is in a web user control into edit mode from the parent page. Basically I am doing this... in...
    3. Replicate rows problem. (TXH CDR:45 Error: Could not read from received stream)
      Hi. I have replicate source-tables to target-tables. Some records not replicates. In ATS file i see such error: TXH Source ID:21 /...
    4. Putting several peices of data in each cell of a datagrid
      You might want to concatenate the fields at the SQL Query level. If you really want to do the combining at the datagrid level then you could indeed...
    5. Upload file and read contents from the stream?
      I would like to provide an interface for users to upload a csv (or other text file). I would like to read the contents of the CSV while it is...
  3. #2

    Default Re: Putting a string onto a stream to be read into a DataGrid

    Most of the time, your code can follow this pattern:

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

    DataBind()
    End If
    End Sub

    When the page is posted back, the grid (or other controls) will populate
    itself from ViewState.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > Hi,
    >
    > Am I trying to hold the data of a DataGrid in a label so that when the
    form
    > is reposted the DataGrid can be repopulated. The problem I am having is
    that
    > I don't understand how to get the text into a stream in order to be able
    to
    > use DataSetOutcomes1.ReadXML(MyStream).
    >
    > Thanks in advance,
    >
    > James
    >
    >
    > Web Form:
    >
    > <%@ Page Language="vb" AutoEventWireup="false"
    > Codebehind="course_new.aspx.vb"
    > Inherits="_1137InsetBookingSystem.course_new"%>
    > <!-- #INCLUDE file="headeraspx.inc" -->
    > <!-- #INCLUDE file="tableheader.inc" -->
    > <form id="FormNewCourse" method="post" runat="server">
    > <table cellSpacing="0" cols="3" cellPadding="0" width="100%" border="0">
    > <tr>
    > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
    > Font-Bold="True">Course Title</asp:label></td>
    > <td><asp:textbox id="txtCourseTitle" runat="server"></asp:textbox></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
    > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > </tr>
    > <tr>
    > <td vAlign="top">&nbsp;</td>
    > <td><asp:textbox id="txtCourseTutor" runat="server"></asp:textbox></td>
    > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    BackColor="#F6CD7A"
    > BorderStyle="Solid" BorderWidth="1px"
    > Width="80px"></asp:button></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
    > TextMode="MultiLine"></asp:textbox></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td colSpan="3"><asp:label id="lblLearningOutcomes" runat="server"
    > Font-Bold="True">Learning Outcomes</asp:label></td>
    > </TD></tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><asp:textbox id="txtOutcome" runat="server"></asp:textbox></td>
    > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
    > BackColor="#F6CD7A" BorderStyle="Solid"
    > BorderWidth="1px" Width="80px"
    > CausesValidation="False"></asp:button></td>
    > </tr>
    > <tr>
    > <td>&nbsp;</td>
    > <td><asp:datagrid id=DataGridOutcomes runat="server" GridLines="None"
    > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
    > DatasetOutcomes1 %>">
    > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <ul>
    > <li>
    > </li>
    > </ul>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > <asp:BoundColumn DataField="Name" SortExpression="Name"
    > HeaderText="Name"></asp:BoundColumn>
    > <asp:BoundColumn DataField="DisplayOrder"
    > SortExpression="DisplayOrder" HeaderText="DisplayOrder"></asp:BoundColumn>
    > <asp:ButtonColumn Text="Delete"
    > ButtonType="PushButton"></asp:ButtonColumn>
    > <asp:ButtonColumn Text="Edit"
    > ButtonType="PushButton"></asp:ButtonColumn>
    > </Columns>
    > </asp:datagrid></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td colSpan="3"><asp:label id="lblOutcomes"
    > runat="server"></asp:label></td>
    > </tr>
    > </table>
    > </form>
    > <!-- #INCLUDE file="tablefooter.inc" -->
    > <!-- #INCLUDE file="footer.inc" -->
    >
    >
    > Code Bind:
    >
    > Imports System
    > Imports System.IO
    > Imports System.Xml
    >
    >
    > Public Class course_new
    > Inherits System.Web.UI.Page
    >
    > #Region " Web Form Designer Generated Code "
    >
    > 'This call is required by the Web Form Designer.
    > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > InitializeComponent()
    > Me.DatasetOutcomes1 = New _1137InsetBookingSystem.DatasetOutcomes
    > CType(Me.DatasetOutcomes1,
    > System.ComponentModel.ISupportInitialize).BeginIni t()
    > '
    > 'DatasetOutcomes1
    > '
    > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > Me.DatasetOutcomes1.Locale = New
    > System.Globalization.CultureInfo("en-GB")
    > CType(Me.DatasetOutcomes1,
    > System.ComponentModel.ISupportInitialize).EndInit( )
    >
    > End Sub
    > Protected WithEvents lblCourseTitle As System.Web.UI.WebControls.Label
    > Protected WithEvents txtCourseTitle As
    System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtCourseTutor As
    System.Web.UI.WebControls.TextBox
    > Protected WithEvents txtTutorList As System.Web.UI.WebControls.TextBox
    > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
    > Protected WithEvents txtOutcome As System.Web.UI.WebControls.TextBox
    > Protected WithEvents cmdAddOutcome As System.Web.UI.WebControls.Button
    > Protected WithEvents lblCourseTutorList As
    > System.Web.UI.WebControls.Label
    > Protected WithEvents lblLearningOutcomes As
    > System.Web.UI.WebControls.Label
    > Protected WithEvents DataGridOutcomes As
    > System.Web.UI.WebControls.DataGrid
    > Protected WithEvents DatasetOutcomes1 As
    > _1137InsetBookingSystem.DatasetOutcomes
    > Protected WithEvents lblOutcomes As System.Web.UI.WebControls.Label
    >
    > 'NOTE: The following placeholder declaration is required by the Web
    Form
    > Designer.
    > 'Do not delete or move it.
    > Private designerPlaceholderDeclaration As System.Object
    >
    > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Init
    > 'CODEGEN: This method call is required by the Web Form Designer
    > 'Do not modify it using the code editor.
    > InitializeComponent()
    > End Sub
    >
    > #End Region
    > Public gstrTableTitle As String = "Create Course"
    > Public gstrTableAttribs As String
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    > If Not Page.IsPostBack Then
    > Me.DataGridOutcomes.DataBind()
    > Else
    > Dim str As String = Me.lblOutcomes.Text
    > Dim MyStream As StreamReader
    >
    > If str.Length > 0 Then
    > MyStream = New StreamReader(str)
    > Me.DatasetOutcomes1.ReadXml(MyStream)
    >
    > End If
    >
    >
    >
    > 'Me.DatasetOutcomes1.GetXml()
    > '
    >
    > End If
    > End Sub
    >
    > Private Sub UpdateOutcomes()
    > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > Me.DataGridOutcomes.DataBind()
    > End Sub
    >
    > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles cmdAdd.Click
    >
    > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1 Then
    > If Me.txtTutorList.Text.Length > 0 Then
    > Me.txtTutorList.Text = Me.txtTutorList.Text & ";" & vbCrLf
    &
    > Me.txtCourseTutor.Text
    > Else
    > Me.txtTutorList.Text = Me.txtCourseTutor.Text
    > End If
    > End If
    > End Sub
    >
    > Private Sub cmdAddOutcome_Click(ByVal sender As System.Object, ByVal e
    > As System.EventArgs) Handles cmdAddOutcome.Click
    > Dim dr As DatasetOutcomes.OutcomesRow
    >
    > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > dr.Item("Name") = Me.txtOutcome.Text
    > dr.Item("DisplayOrder") = Me.DatasetOutcomes1.Outcomes.Rows.Count
    > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    >
    > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > Me.DataGridOutcomes.DataBind()
    >
    > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    >
    > End Sub
    >
    > End Class
    >
    >
    >

    John Saunders Guest

  4. #3

    Default Re: Putting a string onto a stream to be read into a DataGrid

    DatasetCourse is linked to an xml schema to define the data structure and
    the data its self is an xml doc. There is no database behind it, hence the
    need to repopulate from the xml data on postback.


    Schema:
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema id="DatasetOutcomes"
    targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    elementFormDefault="qualified"
    attributeFormDefault="qualified"
    xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    <xs:complexType>
    <xs:choice maxOccurs="unbounded">
    <xs:element name="Outcomes">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Description" type="xs:string" minOccurs="0" />
    <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    <xs:selector xpath=".//mstns:Outcomes" />
    <xs:field xpath="mstns:Description" />
    </xs:key>
    </xs:element>
    </xs:schema>


    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > James,
    >
    > I'm glad you solved your problem, but I'm wondering how you use
    > DatasetCourse on postbacks?
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > Managed to solve it using:
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > 'Put user code to initialize the page here
    > > If Not Page.IsPostBack Then
    > >
    > > Me.DataGridOutcomes.DataBind()
    > > Else
    > > 'Create the XML fragment to be parsed.
    > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > >
    > > If xmlFrag.Length > 0 Then
    > >
    > > 'Create the XmlNamespaceManager.
    > > Dim nt As NameTable = New NameTable
    > > Dim nsmgr As XmlNamespaceManager = New
    > > XmlNamespaceManager(nt)
    > >
    > > 'Create the XmlParserContext.
    > > Dim context As XmlParserContext = New
    > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > >
    > > 'Create the reader.
    > > Dim xmlTR As XmlTextReader = New XmlTextReader(xmlFrag,
    > > XmlNodeType.Element, context)
    > >
    > > Me.DatasetCourse.ReadXml(xmlTR)
    > >
    > > End If
    > > End If
    > > End Sub
    > >
    > >
    > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > Most of the time, your code can follow this pattern:
    > > >
    > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
    > > > System.EventArgs) Handles MyBase.Load
    > > > If Not Page.IsPostBack Then
    > > > myDataSet = GetDataSetSomeHow()
    > > > myDataGrid.DataSource = myDataSet
    > > > myDataGrid.DataMember = "FirstTable"
    > > >
    > > > DataBind()
    > > > End If
    > > > End Sub
    > > >
    > > > When the page is posted back, the grid (or other controls) will
    populate
    > > > itself from ViewState.
    > > > --
    > > > John Saunders
    > > > Internet Engineer
    > > > [email]john.saunders@surfcontrol.com[/email]
    > > >
    > > >
    > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    message
    > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > Hi,
    > > > >
    > > > > Am I trying to hold the data of a DataGrid in a label so that when
    the
    > > > form
    > > > > is reposted the DataGrid can be repopulated. The problem I am having
    > is
    > > > that
    > > > > I don't understand how to get the text into a stream in order to be
    > able
    > > > to
    > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > >
    > > > > Thanks in advance,
    > > > >
    > > > > James
    > > > >
    > > > >
    > > > > Web Form:
    > > > >
    > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > Codebehind="course_new.aspx.vb"
    > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
    > > border="0">
    > > > > <tr>
    > > > > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
    > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > <td><asp:textbox id="txtCourseTitle"
    > > runat="server"></asp:textbox></td>
    > > > > <td>&nbsp;</td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td colSpan="3"><asp:label id="lblCourseTutorList" runat="server"
    > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td vAlign="top">&nbsp;</td>
    > > > > <td><asp:textbox id="txtCourseTutor"
    > > runat="server"></asp:textbox></td>
    > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > BackColor="#F6CD7A"
    > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > Width="80px"></asp:button></td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td>&nbsp;</td>
    > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
    > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > <td>&nbsp;</td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    runat="server"
    > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > </TD></tr>
    > > > > <tr>
    > > > > <td>&nbsp;</td>
    > > > > <td><asp:textbox id="txtOutcome"
    runat="server"></asp:textbox></td>
    > > > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
    > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > BorderWidth="1px" Width="80px"
    > > > > CausesValidation="False"></asp:button></td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td>&nbsp;</td>
    > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > GridLines="None"
    > > > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
    > > > > DatasetOutcomes1 %>">
    > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > <Columns>
    > > > > <asp:TemplateColumn>
    > > > > <ItemTemplate>
    > > > > <ul>
    > > > > <li>
    > > > > </li>
    > > > > </ul>
    > > > > </ItemTemplate>
    > > > > </asp:TemplateColumn>
    > > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
    > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > SortExpression="DisplayOrder"
    > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > <asp:ButtonColumn Text="Delete"
    > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > <asp:ButtonColumn Text="Edit"
    > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > </Columns>
    > > > > </asp:datagrid></td>
    > > > > <td>&nbsp;</td>
    > > > > </tr>
    > > > > <tr>
    > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > runat="server"></asp:label></td>
    > > > > </tr>
    > > > > </table>
    > > > > </form>
    > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > >
    > > > >
    > > > > Code Bind:
    > > > >
    > > > > Imports System
    > > > > Imports System.IO
    > > > > Imports System.Xml
    > > > >
    > > > >
    > > > > Public Class course_new
    > > > > Inherits System.Web.UI.Page
    > > > >
    > > > > #Region " Web Form Designer Generated Code "
    > > > >
    > > > > 'This call is required by the Web Form Designer.
    > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > InitializeComponent()
    > > > > Me.DatasetOutcomes1 = New
    > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > CType(Me.DatasetOutcomes1,
    > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > '
    > > > > 'DatasetOutcomes1
    > > > > '
    > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > > > > Me.DatasetOutcomes1.Locale = New
    > > > > System.Globalization.CultureInfo("en-GB")
    > > > > CType(Me.DatasetOutcomes1,
    > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > >
    > > > > End Sub
    > > > > Protected WithEvents lblCourseTitle As
    > > System.Web.UI.WebControls.Label
    > > > > Protected WithEvents txtCourseTitle As
    > > > System.Web.UI.WebControls.TextBox
    > > > > Protected WithEvents txtCourseTutor As
    > > > System.Web.UI.WebControls.TextBox
    > > > > Protected WithEvents txtTutorList As
    > > System.Web.UI.WebControls.TextBox
    > > > > Protected WithEvents cmdAdd As System.Web.UI.WebControls.Button
    > > > > Protected WithEvents txtOutcome As
    > System.Web.UI.WebControls.TextBox
    > > > > Protected WithEvents cmdAddOutcome As
    > > System.Web.UI.WebControls.Button
    > > > > Protected WithEvents lblCourseTutorList As
    > > > > System.Web.UI.WebControls.Label
    > > > > Protected WithEvents lblLearningOutcomes As
    > > > > System.Web.UI.WebControls.Label
    > > > > Protected WithEvents DataGridOutcomes As
    > > > > System.Web.UI.WebControls.DataGrid
    > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > Protected WithEvents lblOutcomes As
    > System.Web.UI.WebControls.Label
    > > > >
    > > > > 'NOTE: The following placeholder declaration is required by the
    > Web
    > > > Form
    > > > > Designer.
    > > > > 'Do not delete or move it.
    > > > > Private designerPlaceholderDeclaration As System.Object
    > > > >
    > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
    > > > > System.EventArgs) Handles MyBase.Init
    > > > > 'CODEGEN: This method call is required by the Web Form
    > Designer
    > > > > 'Do not modify it using the code editor.
    > > > > InitializeComponent()
    > > > > End Sub
    > > > >
    > > > > #End Region
    > > > > Public gstrTableTitle As String = "Create Course"
    > > > > Public gstrTableAttribs As String
    > > > >
    > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > > System.EventArgs) Handles MyBase.Load
    > > > > 'Put user code to initialize the page here
    > > > > If Not Page.IsPostBack Then
    > > > > Me.DataGridOutcomes.DataBind()
    > > > > Else
    > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > Dim MyStream As StreamReader
    > > > >
    > > > > If str.Length > 0 Then
    > > > > MyStream = New StreamReader(str)
    > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > >
    > > > > End If
    > > > >
    > > > >
    > > > >
    > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > '
    > > > >
    > > > > End If
    > > > > End Sub
    > > > >
    > > > > Private Sub UpdateOutcomes()
    > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > > > > Me.DataGridOutcomes.DataBind()
    > > > > End Sub
    > > > >
    > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e
    As
    > > > > System.EventArgs) Handles cmdAdd.Click
    > > > >
    > > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1
    > Then
    > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";" &
    > > vbCrLf
    > > > &
    > > > > Me.txtCourseTutor.Text
    > > > > Else
    > > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
    > > > > End If
    > > > > End If
    > > > > End Sub
    > > > >
    > > > > Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,
    > ByVal
    > > e
    > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > >
    > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > dr.Item("DisplayOrder") =
    > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > >
    > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > Me.DataGridOutcomes.DataBind()
    > > > >
    > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > >
    > > > > End Sub
    > > > >
    > > > > End Class
    > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    James Norton-Jones Guest

  5. #4

    Default Re: Putting a string onto a stream to be read into a DataGrid

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

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

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

    "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > DatasetCourse is linked to an xml schema to define the data structure and
    > the data its self is an xml doc. There is no database behind it, hence the
    > need to repopulate from the xml data on postback.
    >
    >
    > Schema:
    > <?xml version="1.0" encoding="utf-8" ?>
    > <xs:schema id="DatasetOutcomes"
    > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > elementFormDefault="qualified"
    > attributeFormDefault="qualified"
    > xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > <xs:complexType>
    > <xs:choice maxOccurs="unbounded">
    > <xs:element name="Outcomes">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="Description" type="xs:string" minOccurs="0" />
    > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > </xs:choice>
    > </xs:complexType>
    > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > <xs:selector xpath=".//mstns:Outcomes" />
    > <xs:field xpath="mstns:Description" />
    > </xs:key>
    > </xs:element>
    > </xs:schema>
    >
    >
    > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > James,
    > >
    > > I'm glad you solved your problem, but I'm wondering how you use
    > > DatasetCourse on postbacks?
    > > --
    > > John Saunders
    > > Internet Engineer
    > > [email]john.saunders@surfcontrol.com[/email]
    > >
    > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > Managed to solve it using:
    > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > System.EventArgs) Handles MyBase.Load
    > > > 'Put user code to initialize the page here
    > > > If Not Page.IsPostBack Then
    > > >
    > > > Me.DataGridOutcomes.DataBind()
    > > > Else
    > > > 'Create the XML fragment to be parsed.
    > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > >
    > > > If xmlFrag.Length > 0 Then
    > > >
    > > > 'Create the XmlNamespaceManager.
    > > > Dim nt As NameTable = New NameTable
    > > > Dim nsmgr As XmlNamespaceManager = New
    > > > XmlNamespaceManager(nt)
    > > >
    > > > 'Create the XmlParserContext.
    > > > Dim context As XmlParserContext = New
    > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > >
    > > > 'Create the reader.
    > > > Dim xmlTR As XmlTextReader = New
    XmlTextReader(xmlFrag,
    > > > XmlNodeType.Element, context)
    > > >
    > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > >
    > > > End If
    > > > End If
    > > > End Sub
    > > >
    > > >
    > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > Most of the time, your code can follow this pattern:
    > > > >
    > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
    > > > > System.EventArgs) Handles MyBase.Load
    > > > > If Not Page.IsPostBack Then
    > > > > myDataSet = GetDataSetSomeHow()
    > > > > myDataGrid.DataSource = myDataSet
    > > > > myDataGrid.DataMember = "FirstTable"
    > > > >
    > > > > DataBind()
    > > > > End If
    > > > > End Sub
    > > > >
    > > > > When the page is posted back, the grid (or other controls) will
    > populate
    > > > > itself from ViewState.
    > > > > --
    > > > > John Saunders
    > > > > Internet Engineer
    > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > >
    > > > >
    > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > message
    > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > Hi,
    > > > > >
    > > > > > Am I trying to hold the data of a DataGrid in a label so that when
    > the
    > > > > form
    > > > > > is reposted the DataGrid can be repopulated. The problem I am
    having
    > > is
    > > > > that
    > > > > > I don't understand how to get the text into a stream in order to
    be
    > > able
    > > > > to
    > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > >
    > > > > > Thanks in advance,
    > > > > >
    > > > > > James
    > > > > >
    > > > > >
    > > > > > Web Form:
    > > > > >
    > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > Codebehind="course_new.aspx.vb"
    > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
    > > > border="0">
    > > > > > <tr>
    > > > > > <td vAlign="top"><asp:label id="lblCourseTitle" runat="server"
    > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > runat="server"></asp:textbox></td>
    > > > > > <td>&nbsp;</td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    runat="server"
    > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > runat="server"></asp:textbox></td>
    > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > BackColor="#F6CD7A"
    > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > Width="80px"></asp:button></td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td>&nbsp;</td>
    > > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
    > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > <td>&nbsp;</td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > runat="server"
    > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > </TD></tr>
    > > > > > <tr>
    > > > > > <td>&nbsp;</td>
    > > > > > <td><asp:textbox id="txtOutcome"
    > runat="server"></asp:textbox></td>
    > > > > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
    > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > BorderWidth="1px" Width="80px"
    > > > > > CausesValidation="False"></asp:button></td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td>&nbsp;</td>
    > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > GridLines="None"
    > > > > > AutoGenerateColumns="False" DataMember="Outcomes" DataSource="<%#
    > > > > > DatasetOutcomes1 %>">
    > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > <Columns>
    > > > > > <asp:TemplateColumn>
    > > > > > <ItemTemplate>
    > > > > > <ul>
    > > > > > <li>
    > > > > > </li>
    > > > > > </ul>
    > > > > > </ItemTemplate>
    > > > > > </asp:TemplateColumn>
    > > > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
    > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > SortExpression="DisplayOrder"
    > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > </Columns>
    > > > > > </asp:datagrid></td>
    > > > > > <td>&nbsp;</td>
    > > > > > </tr>
    > > > > > <tr>
    > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > runat="server"></asp:label></td>
    > > > > > </tr>
    > > > > > </table>
    > > > > > </form>
    > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > >
    > > > > >
    > > > > > Code Bind:
    > > > > >
    > > > > > Imports System
    > > > > > Imports System.IO
    > > > > > Imports System.Xml
    > > > > >
    > > > > >
    > > > > > Public Class course_new
    > > > > > Inherits System.Web.UI.Page
    > > > > >
    > > > > > #Region " Web Form Designer Generated Code "
    > > > > >
    > > > > > 'This call is required by the Web Form Designer.
    > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > > InitializeComponent()
    > > > > > Me.DatasetOutcomes1 = New
    > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > CType(Me.DatasetOutcomes1,
    > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > '
    > > > > > 'DatasetOutcomes1
    > > > > > '
    > > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > CType(Me.DatasetOutcomes1,
    > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > >
    > > > > > End Sub
    > > > > > Protected WithEvents lblCourseTitle As
    > > > System.Web.UI.WebControls.Label
    > > > > > Protected WithEvents txtCourseTitle As
    > > > > System.Web.UI.WebControls.TextBox
    > > > > > Protected WithEvents txtCourseTutor As
    > > > > System.Web.UI.WebControls.TextBox
    > > > > > Protected WithEvents txtTutorList As
    > > > System.Web.UI.WebControls.TextBox
    > > > > > Protected WithEvents cmdAdd As
    System.Web.UI.WebControls.Button
    > > > > > Protected WithEvents txtOutcome As
    > > System.Web.UI.WebControls.TextBox
    > > > > > Protected WithEvents cmdAddOutcome As
    > > > System.Web.UI.WebControls.Button
    > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > System.Web.UI.WebControls.Label
    > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > System.Web.UI.WebControls.Label
    > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > Protected WithEvents lblOutcomes As
    > > System.Web.UI.WebControls.Label
    > > > > >
    > > > > > 'NOTE: The following placeholder declaration is required by
    the
    > > Web
    > > > > Form
    > > > > > Designer.
    > > > > > 'Do not delete or move it.
    > > > > > Private designerPlaceholderDeclaration As System.Object
    > > > > >
    > > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
    As
    > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > 'CODEGEN: This method call is required by the Web Form
    > > Designer
    > > > > > 'Do not modify it using the code editor.
    > > > > > InitializeComponent()
    > > > > > End Sub
    > > > > >
    > > > > > #End Region
    > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > Public gstrTableAttribs As String
    > > > > >
    > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e
    As
    > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > 'Put user code to initialize the page here
    > > > > > If Not Page.IsPostBack Then
    > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > Else
    > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > Dim MyStream As StreamReader
    > > > > >
    > > > > > If str.Length > 0 Then
    > > > > > MyStream = New StreamReader(str)
    > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > >
    > > > > > End If
    > > > > >
    > > > > >
    > > > > >
    > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > '
    > > > > >
    > > > > > End If
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub UpdateOutcomes()
    > > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal
    e
    > As
    > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > >
    > > > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) < 1
    > > Then
    > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > Me.txtTutorList.Text = Me.txtTutorList.Text & ";"
    &
    > > > vbCrLf
    > > > > &
    > > > > > Me.txtCourseTutor.Text
    > > > > > Else
    > > > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
    > > > > > End If
    > > > > > End If
    > > > > > End Sub
    > > > > >
    > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As System.Object,
    > > ByVal
    > > > e
    > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > >
    > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > dr.Item("DisplayOrder") =
    > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > >
    > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > Me.DataGridOutcomes.DataBind()
    > > > > >
    > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > End Class
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    John Saunders Guest

  6. #5

    Default Re: Putting a string onto a stream to be read into a DataGrid

    Session:

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

    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:uhyw7eBWDHA.1896@TK2MSFTNGP12.phx.gbl...
    > Ok, I don't think I've ever used an updateable XML file yet, so I didn't
    see
    > that. In order to update even a single row, you have to read in the entire
    > file.
    >
    > Please pardon me for being dense, was your question ever actually
    answered?
    > :-)
    >
    > If I were you, I think I'd store DatasetCourse in Session state. On the
    > other hand, if you're going to be making multiple changes to the data per
    > session, I think I'd keep it in Session, but flush to disk whenever a
    change
    > was made. That way, if the session expires (seen as
    Session("DatasetCourse")
    > Is Nothing), then you can re-load it from the disk file (which you'll need
    > to uniquely name, without resorting to the Session ID!)
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > > DatasetCourse is linked to an xml schema to define the data structure
    and
    > > the data its self is an xml doc. There is no database behind it, hence
    the
    > > need to repopulate from the xml data on postback.
    > >
    > >
    > > Schema:
    > > <?xml version="1.0" encoding="utf-8" ?>
    > > <xs:schema id="DatasetOutcomes"
    > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > > elementFormDefault="qualified"
    > > attributeFormDefault="qualified"
    > >
    xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > > <xs:complexType>
    > > <xs:choice maxOccurs="unbounded">
    > > <xs:element name="Outcomes">
    > > <xs:complexType>
    > > <xs:sequence>
    > > <xs:element name="Description" type="xs:string" minOccurs="0" />
    > > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
    > > </xs:sequence>
    > > </xs:complexType>
    > > </xs:element>
    > > </xs:choice>
    > > </xs:complexType>
    > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > > <xs:selector xpath=".//mstns:Outcomes" />
    > > <xs:field xpath="mstns:Description" />
    > > </xs:key>
    > > </xs:element>
    > > </xs:schema>
    > >
    > >
    > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > > James,
    > > >
    > > > I'm glad you solved your problem, but I'm wondering how you use
    > > > DatasetCourse on postbacks?
    > > > --
    > > > John Saunders
    > > > Internet Engineer
    > > > [email]john.saunders@surfcontrol.com[/email]
    > > >
    > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    message
    > > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > > Managed to solve it using:
    > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > > > System.EventArgs) Handles MyBase.Load
    > > > > 'Put user code to initialize the page here
    > > > > If Not Page.IsPostBack Then
    > > > >
    > > > > Me.DataGridOutcomes.DataBind()
    > > > > Else
    > > > > 'Create the XML fragment to be parsed.
    > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > > >
    > > > > If xmlFrag.Length > 0 Then
    > > > >
    > > > > 'Create the XmlNamespaceManager.
    > > > > Dim nt As NameTable = New NameTable
    > > > > Dim nsmgr As XmlNamespaceManager = New
    > > > > XmlNamespaceManager(nt)
    > > > >
    > > > > 'Create the XmlParserContext.
    > > > > Dim context As XmlParserContext = New
    > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > > >
    > > > > 'Create the reader.
    > > > > Dim xmlTR As XmlTextReader = New
    > XmlTextReader(xmlFrag,
    > > > > XmlNodeType.Element, context)
    > > > >
    > > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > > >
    > > > > End If
    > > > > End If
    > > > > End Sub
    > > > >
    > > > >
    > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > > Most of the time, your code can follow this pattern:
    > > > > >
    > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
    > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > If Not Page.IsPostBack Then
    > > > > > myDataSet = GetDataSetSomeHow()
    > > > > > myDataGrid.DataSource = myDataSet
    > > > > > myDataGrid.DataMember = "FirstTable"
    > > > > >
    > > > > > DataBind()
    > > > > > End If
    > > > > > End Sub
    > > > > >
    > > > > > When the page is posted back, the grid (or other controls) will
    > > populate
    > > > > > itself from ViewState.
    > > > > > --
    > > > > > John Saunders
    > > > > > Internet Engineer
    > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > >
    > > > > >
    > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > > message
    > > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > > Hi,
    > > > > > >
    > > > > > > Am I trying to hold the data of a DataGrid in a label so that
    when
    > > the
    > > > > > form
    > > > > > > is reposted the DataGrid can be repopulated. The problem I am
    > having
    > > > is
    > > > > > that
    > > > > > > I don't understand how to get the text into a stream in order to
    > be
    > > > able
    > > > > > to
    > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > > >
    > > > > > > Thanks in advance,
    > > > > > >
    > > > > > > James
    > > > > > >
    > > > > > >
    > > > > > > Web Form:
    > > > > > >
    > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > > Codebehind="course_new.aspx.vb"
    > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
    > > > > border="0">
    > > > > > > <tr>
    > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
    runat="server"
    > > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > > runat="server"></asp:textbox></td>
    > > > > > > <td>&nbsp;</td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    > runat="server"
    > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > > runat="server"></asp:textbox></td>
    > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > > BackColor="#F6CD7A"
    > > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > > Width="80px"></asp:button></td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td>&nbsp;</td>
    > > > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
    > > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > > <td>&nbsp;</td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > > runat="server"
    > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > > </TD></tr>
    > > > > > > <tr>
    > > > > > > <td>&nbsp;</td>
    > > > > > > <td><asp:textbox id="txtOutcome"
    > > runat="server"></asp:textbox></td>
    > > > > > > <td><asp:button id="cmdAddOutcome" runat="server" Text="Add"
    > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > > BorderWidth="1px" Width="80px"
    > > > > > > CausesValidation="False"></asp:button></td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td>&nbsp;</td>
    > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > > GridLines="None"
    > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
    DataSource="<%#
    > > > > > > DatasetOutcomes1 %>">
    > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > > <Columns>
    > > > > > > <asp:TemplateColumn>
    > > > > > > <ItemTemplate>
    > > > > > > <ul>
    > > > > > > <li>
    > > > > > > </li>
    > > > > > > </ul>
    > > > > > > </ItemTemplate>
    > > > > > > </asp:TemplateColumn>
    > > > > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
    > > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > > SortExpression="DisplayOrder"
    > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > </Columns>
    > > > > > > </asp:datagrid></td>
    > > > > > > <td>&nbsp;</td>
    > > > > > > </tr>
    > > > > > > <tr>
    > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > > runat="server"></asp:label></td>
    > > > > > > </tr>
    > > > > > > </table>
    > > > > > > </form>
    > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > > >
    > > > > > >
    > > > > > > Code Bind:
    > > > > > >
    > > > > > > Imports System
    > > > > > > Imports System.IO
    > > > > > > Imports System.Xml
    > > > > > >
    > > > > > >
    > > > > > > Public Class course_new
    > > > > > > Inherits System.Web.UI.Page
    > > > > > >
    > > > > > > #Region " Web Form Designer Generated Code "
    > > > > > >
    > > > > > > 'This call is required by the Web Form Designer.
    > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > > > InitializeComponent()
    > > > > > > Me.DatasetOutcomes1 = New
    > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > > '
    > > > > > > 'DatasetOutcomes1
    > > > > > > '
    > > > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > > >
    > > > > > > End Sub
    > > > > > > Protected WithEvents lblCourseTitle As
    > > > > System.Web.UI.WebControls.Label
    > > > > > > Protected WithEvents txtCourseTitle As
    > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > Protected WithEvents txtCourseTutor As
    > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > Protected WithEvents txtTutorList As
    > > > > System.Web.UI.WebControls.TextBox
    > > > > > > Protected WithEvents cmdAdd As
    > System.Web.UI.WebControls.Button
    > > > > > > Protected WithEvents txtOutcome As
    > > > System.Web.UI.WebControls.TextBox
    > > > > > > Protected WithEvents cmdAddOutcome As
    > > > > System.Web.UI.WebControls.Button
    > > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > > System.Web.UI.WebControls.Label
    > > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > > System.Web.UI.WebControls.Label
    > > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > Protected WithEvents lblOutcomes As
    > > > System.Web.UI.WebControls.Label
    > > > > > >
    > > > > > > 'NOTE: The following placeholder declaration is required by
    > the
    > > > Web
    > > > > > Form
    > > > > > > Designer.
    > > > > > > 'Do not delete or move it.
    > > > > > > Private designerPlaceholderDeclaration As System.Object
    > > > > > >
    > > > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal e
    > As
    > > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > > 'CODEGEN: This method call is required by the Web Form
    > > > Designer
    > > > > > > 'Do not modify it using the code editor.
    > > > > > > InitializeComponent()
    > > > > > > End Sub
    > > > > > >
    > > > > > > #End Region
    > > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > > Public gstrTableAttribs As String
    > > > > > >
    > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e
    > As
    > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > 'Put user code to initialize the page here
    > > > > > > If Not Page.IsPostBack Then
    > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > Else
    > > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > > Dim MyStream As StreamReader
    > > > > > >
    > > > > > > If str.Length > 0 Then
    > > > > > > MyStream = New StreamReader(str)
    > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > > >
    > > > > > > End If
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > > '
    > > > > > >
    > > > > > > End If
    > > > > > > End Sub
    > > > > > >
    > > > > > > Private Sub UpdateOutcomes()
    > > > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > End Sub
    > > > > > >
    > > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object,
    ByVal
    > e
    > > As
    > > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > > >
    > > > > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text) <
    1
    > > > Then
    > > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > > Me.txtTutorList.Text = Me.txtTutorList.Text &
    ";"
    > &
    > > > > vbCrLf
    > > > > > &
    > > > > > > Me.txtCourseTutor.Text
    > > > > > > Else
    > > > > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
    > > > > > > End If
    > > > > > > End If
    > > > > > > End Sub
    > > > > > >
    > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
    System.Object,
    > > > ByVal
    > > > > e
    > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > > >
    > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > > dr.Item("DisplayOrder") =
    > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > > >
    > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > >
    > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > > >
    > > > > > > End Sub
    > > > > > >
    > > > > > > End Class
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    James Norton-Jones Guest

  7. #6

    Default Re: Putting a string onto a stream to be read into a DataGrid

    Runs on multiple servers - and no Sql Server database to store session state
    in.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]

    "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    news:3f2a4401$0$10773$afc38c87@news.easynet.co.uk. ..
    > Session:
    >
    > Not able to do that as it will run on multiple servers.
    >
    > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > news:uhyw7eBWDHA.1896@TK2MSFTNGP12.phx.gbl...
    > > Ok, I don't think I've ever used an updateable XML file yet, so I didn't
    > see
    > > that. In order to update even a single row, you have to read in the
    entire
    > > file.
    > >
    > > Please pardon me for being dense, was your question ever actually
    > answered?
    > > :-)
    > >
    > > If I were you, I think I'd store DatasetCourse in Session state. On the
    > > other hand, if you're going to be making multiple changes to the data
    per
    > > session, I think I'd keep it in Session, but flush to disk whenever a
    > change
    > > was made. That way, if the session expires (seen as
    > Session("DatasetCourse")
    > > Is Nothing), then you can re-load it from the disk file (which you'll
    need
    > > to uniquely name, without resorting to the Session ID!)
    > > --
    > > John Saunders
    > > Internet Engineer
    > > [email]john.saunders@surfcontrol.com[/email]
    > >
    > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > > news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > > > DatasetCourse is linked to an xml schema to define the data structure
    > and
    > > > the data its self is an xml doc. There is no database behind it, hence
    > the
    > > > need to repopulate from the xml data on postback.
    > > >
    > > >
    > > > Schema:
    > > > <?xml version="1.0" encoding="utf-8" ?>
    > > > <xs:schema id="DatasetOutcomes"
    > > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > > > elementFormDefault="qualified"
    > > > attributeFormDefault="qualified"
    > > >
    > xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > > > <xs:complexType>
    > > > <xs:choice maxOccurs="unbounded">
    > > > <xs:element name="Outcomes">
    > > > <xs:complexType>
    > > > <xs:sequence>
    > > > <xs:element name="Description" type="xs:string" minOccurs="0"
    />
    > > > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0" />
    > > > </xs:sequence>
    > > > </xs:complexType>
    > > > </xs:element>
    > > > </xs:choice>
    > > > </xs:complexType>
    > > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > > > <xs:selector xpath=".//mstns:Outcomes" />
    > > > <xs:field xpath="mstns:Description" />
    > > > </xs:key>
    > > > </xs:element>
    > > > </xs:schema>
    > > >
    > > >
    > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > > > James,
    > > > >
    > > > > I'm glad you solved your problem, but I'm wondering how you use
    > > > > DatasetCourse on postbacks?
    > > > > --
    > > > > John Saunders
    > > > > Internet Engineer
    > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > >
    > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > message
    > > > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > > > Managed to solve it using:
    > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e
    As
    > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > 'Put user code to initialize the page here
    > > > > > If Not Page.IsPostBack Then
    > > > > >
    > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > Else
    > > > > > 'Create the XML fragment to be parsed.
    > > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > > > >
    > > > > > If xmlFrag.Length > 0 Then
    > > > > >
    > > > > > 'Create the XmlNamespaceManager.
    > > > > > Dim nt As NameTable = New NameTable
    > > > > > Dim nsmgr As XmlNamespaceManager = New
    > > > > > XmlNamespaceManager(nt)
    > > > > >
    > > > > > 'Create the XmlParserContext.
    > > > > > Dim context As XmlParserContext = New
    > > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > > > >
    > > > > > 'Create the reader.
    > > > > > Dim xmlTR As XmlTextReader = New
    > > XmlTextReader(xmlFrag,
    > > > > > XmlNodeType.Element, context)
    > > > > >
    > > > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > > > >
    > > > > > End If
    > > > > > End If
    > > > > > End Sub
    > > > > >
    > > > > >
    > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > > > Most of the time, your code can follow this pattern:
    > > > > > >
    > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a As
    > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > If Not Page.IsPostBack Then
    > > > > > > myDataSet = GetDataSetSomeHow()
    > > > > > > myDataGrid.DataSource = myDataSet
    > > > > > > myDataGrid.DataMember = "FirstTable"
    > > > > > >
    > > > > > > DataBind()
    > > > > > > End If
    > > > > > > End Sub
    > > > > > >
    > > > > > > When the page is posted back, the grid (or other controls) will
    > > > populate
    > > > > > > itself from ViewState.
    > > > > > > --
    > > > > > > John Saunders
    > > > > > > Internet Engineer
    > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > >
    > > > > > >
    > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > > > message
    > > > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > > > Hi,
    > > > > > > >
    > > > > > > > Am I trying to hold the data of a DataGrid in a label so that
    > when
    > > > the
    > > > > > > form
    > > > > > > > is reposted the DataGrid can be repopulated. The problem I am
    > > having
    > > > > is
    > > > > > > that
    > > > > > > > I don't understand how to get the text into a stream in order
    to
    > > be
    > > > > able
    > > > > > > to
    > > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > > > >
    > > > > > > > Thanks in advance,
    > > > > > > >
    > > > > > > > James
    > > > > > > >
    > > > > > > >
    > > > > > > > Web Form:
    > > > > > > >
    > > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > > > Codebehind="course_new.aspx.vb"
    > > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > > > <table cellSpacing="0" cols="3" cellPadding="0" width="100%"
    > > > > > border="0">
    > > > > > > > <tr>
    > > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
    > runat="server"
    > > > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > > > runat="server"></asp:textbox></td>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    > > runat="server"
    > > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > > > runat="server"></asp:textbox></td>
    > > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > > > BackColor="#F6CD7A"
    > > > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > > > Width="80px"></asp:button></td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > <td><asp:textbox id="txtTutorList" runat="server" Rows="5"
    > > > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > > > runat="server"
    > > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > > > </TD></tr>
    > > > > > > > <tr>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > <td><asp:textbox id="txtOutcome"
    > > > runat="server"></asp:textbox></td>
    > > > > > > > <td><asp:button id="cmdAddOutcome" runat="server"
    Text="Add"
    > > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > > > BorderWidth="1px" Width="80px"
    > > > > > > > CausesValidation="False"></asp:button></td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > > > GridLines="None"
    > > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
    > DataSource="<%#
    > > > > > > > DatasetOutcomes1 %>">
    > > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > > > <Columns>
    > > > > > > > <asp:TemplateColumn>
    > > > > > > > <ItemTemplate>
    > > > > > > > <ul>
    > > > > > > > <li>
    > > > > > > > </li>
    > > > > > > > </ul>
    > > > > > > > </ItemTemplate>
    > > > > > > > </asp:TemplateColumn>
    > > > > > > > <asp:BoundColumn DataField="Name" SortExpression="Name"
    > > > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > > > SortExpression="DisplayOrder"
    > > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > </Columns>
    > > > > > > > </asp:datagrid></td>
    > > > > > > > <td>&nbsp;</td>
    > > > > > > > </tr>
    > > > > > > > <tr>
    > > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > > > runat="server"></asp:label></td>
    > > > > > > > </tr>
    > > > > > > > </table>
    > > > > > > > </form>
    > > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > > > >
    > > > > > > >
    > > > > > > > Code Bind:
    > > > > > > >
    > > > > > > > Imports System
    > > > > > > > Imports System.IO
    > > > > > > > Imports System.Xml
    > > > > > > >
    > > > > > > >
    > > > > > > > Public Class course_new
    > > > > > > > Inherits System.Web.UI.Page
    > > > > > > >
    > > > > > > > #Region " Web Form Designer Generated Code "
    > > > > > > >
    > > > > > > > 'This call is required by the Web Form Designer.
    > > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > > > > InitializeComponent()
    > > > > > > > Me.DatasetOutcomes1 = New
    > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > > > '
    > > > > > > > 'DatasetOutcomes1
    > > > > > > > '
    > > > > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > > > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > > Protected WithEvents lblCourseTitle As
    > > > > > System.Web.UI.WebControls.Label
    > > > > > > > Protected WithEvents txtCourseTitle As
    > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > Protected WithEvents txtCourseTutor As
    > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > Protected WithEvents txtTutorList As
    > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > Protected WithEvents cmdAdd As
    > > System.Web.UI.WebControls.Button
    > > > > > > > Protected WithEvents txtOutcome As
    > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > Protected WithEvents cmdAddOutcome As
    > > > > > System.Web.UI.WebControls.Button
    > > > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > Protected WithEvents lblOutcomes As
    > > > > System.Web.UI.WebControls.Label
    > > > > > > >
    > > > > > > > 'NOTE: The following placeholder declaration is required
    by
    > > the
    > > > > Web
    > > > > > > Form
    > > > > > > > Designer.
    > > > > > > > 'Do not delete or move it.
    > > > > > > > Private designerPlaceholderDeclaration As System.Object
    > > > > > > >
    > > > > > > > Private Sub Page_Init(ByVal sender As System.Object, ByVal
    e
    > > As
    > > > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > > > 'CODEGEN: This method call is required by the Web Form
    > > > > Designer
    > > > > > > > 'Do not modify it using the code editor.
    > > > > > > > InitializeComponent()
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > #End Region
    > > > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > > > Public gstrTableAttribs As String
    > > > > > > >
    > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
    e
    > > As
    > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > 'Put user code to initialize the page here
    > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > Else
    > > > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > > > Dim MyStream As StreamReader
    > > > > > > >
    > > > > > > > If str.Length > 0 Then
    > > > > > > > MyStream = New StreamReader(str)
    > > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > > > >
    > > > > > > > End If
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > > > '
    > > > > > > >
    > > > > > > > End If
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > Private Sub UpdateOutcomes()
    > > > > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object,
    > ByVal
    > > e
    > > > As
    > > > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > > > >
    > > > > > > > If InStr(Me.txtTutorList.Text, Me.txtCourseTutor.Text)
    <
    > 1
    > > > > Then
    > > > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > > > Me.txtTutorList.Text = Me.txtTutorList.Text &
    > ";"
    > > &
    > > > > > vbCrLf
    > > > > > > &
    > > > > > > > Me.txtCourseTutor.Text
    > > > > > > > Else
    > > > > > > > Me.txtTutorList.Text = Me.txtCourseTutor.Text
    > > > > > > > End If
    > > > > > > > End If
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
    > System.Object,
    > > > > ByVal
    > > > > > e
    > > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > > > >
    > > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > > > dr.Item("DisplayOrder") =
    > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > > > >
    > > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > >
    > > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > > > >
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > End Class
    > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    John Saunders Guest

  8. #7

    Default Re: Putting a string onto a stream to be read into a DataGrid

    It will eventually be written to a SQL DB but each of the data grid items
    will relate to the new course record. As such the course details need top be
    completed on the form.Once all the course details have been captured the
    data will be split into several tables. Each of the outcome rows will relate
    to one course record and will be held in a table call tblCourseOutcomes. I
    did want to get into a situation of create temp record in the DB.


    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:OZvwKnBWDHA.1872@TK2MSFTNGP12.phx.gbl...
    > Runs on multiple servers - and no Sql Server database to store session
    state
    > in.
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > news:3f2a4401$0$10773$afc38c87@news.easynet.co.uk. ..
    > > Session:
    > >
    > > Not able to do that as it will run on multiple servers.
    > >
    > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > news:uhyw7eBWDHA.1896@TK2MSFTNGP12.phx.gbl...
    > > > Ok, I don't think I've ever used an updateable XML file yet, so I
    didn't
    > > see
    > > > that. In order to update even a single row, you have to read in the
    > entire
    > > > file.
    > > >
    > > > Please pardon me for being dense, was your question ever actually
    > > answered?
    > > > :-)
    > > >
    > > > If I were you, I think I'd store DatasetCourse in Session state. On
    the
    > > > other hand, if you're going to be making multiple changes to the data
    > per
    > > > session, I think I'd keep it in Session, but flush to disk whenever a
    > > change
    > > > was made. That way, if the session expires (seen as
    > > Session("DatasetCourse")
    > > > Is Nothing), then you can re-load it from the disk file (which you'll
    > need
    > > > to uniquely name, without resorting to the Session ID!)
    > > > --
    > > > John Saunders
    > > > Internet Engineer
    > > > [email]john.saunders@surfcontrol.com[/email]
    > > >
    > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    message
    > > > news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > > > > DatasetCourse is linked to an xml schema to define the data
    structure
    > > and
    > > > > the data its self is an xml doc. There is no database behind it,
    hence
    > > the
    > > > > need to repopulate from the xml data on postback.
    > > > >
    > > > >
    > > > > Schema:
    > > > > <?xml version="1.0" encoding="utf-8" ?>
    > > > > <xs:schema id="DatasetOutcomes"
    > > > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > elementFormDefault="qualified"
    > > > > attributeFormDefault="qualified"
    > > > >
    > >
    xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > > > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > > > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > > > > <xs:complexType>
    > > > > <xs:choice maxOccurs="unbounded">
    > > > > <xs:element name="Outcomes">
    > > > > <xs:complexType>
    > > > > <xs:sequence>
    > > > > <xs:element name="Description" type="xs:string" minOccurs="0"
    > />
    > > > > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0"
    />
    > > > > </xs:sequence>
    > > > > </xs:complexType>
    > > > > </xs:element>
    > > > > </xs:choice>
    > > > > </xs:complexType>
    > > > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > > > > <xs:selector xpath=".//mstns:Outcomes" />
    > > > > <xs:field xpath="mstns:Description" />
    > > > > </xs:key>
    > > > > </xs:element>
    > > > > </xs:schema>
    > > > >
    > > > >
    > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > > > > James,
    > > > > >
    > > > > > I'm glad you solved your problem, but I'm wondering how you use
    > > > > > DatasetCourse on postbacks?
    > > > > > --
    > > > > > John Saunders
    > > > > > Internet Engineer
    > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > >
    > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > > message
    > > > > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > > > > Managed to solve it using:
    > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e
    > As
    > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > 'Put user code to initialize the page here
    > > > > > > If Not Page.IsPostBack Then
    > > > > > >
    > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > Else
    > > > > > > 'Create the XML fragment to be parsed.
    > > > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > > > > >
    > > > > > > If xmlFrag.Length > 0 Then
    > > > > > >
    > > > > > > 'Create the XmlNamespaceManager.
    > > > > > > Dim nt As NameTable = New NameTable
    > > > > > > Dim nsmgr As XmlNamespaceManager = New
    > > > > > > XmlNamespaceManager(nt)
    > > > > > >
    > > > > > > 'Create the XmlParserContext.
    > > > > > > Dim context As XmlParserContext = New
    > > > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > > > > >
    > > > > > > 'Create the reader.
    > > > > > > Dim xmlTR As XmlTextReader = New
    > > > XmlTextReader(xmlFrag,
    > > > > > > XmlNodeType.Element, context)
    > > > > > >
    > > > > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > > > > >
    > > > > > > End If
    > > > > > > End If
    > > > > > > End Sub
    > > > > > >
    > > > > > >
    > > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > > > > Most of the time, your code can follow this pattern:
    > > > > > > >
    > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a
    As
    > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > myDataSet = GetDataSetSomeHow()
    > > > > > > > myDataGrid.DataSource = myDataSet
    > > > > > > > myDataGrid.DataMember = "FirstTable"
    > > > > > > >
    > > > > > > > DataBind()
    > > > > > > > End If
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > > When the page is posted back, the grid (or other controls)
    will
    > > > > populate
    > > > > > > > itself from ViewState.
    > > > > > > > --
    > > > > > > > John Saunders
    > > > > > > > Internet Engineer
    > > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > > >
    > > > > > > >
    > > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote
    in
    > > > > message
    > > > > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > > > > Hi,
    > > > > > > > >
    > > > > > > > > Am I trying to hold the data of a DataGrid in a label so
    that
    > > when
    > > > > the
    > > > > > > > form
    > > > > > > > > is reposted the DataGrid can be repopulated. The problem I
    am
    > > > having
    > > > > > is
    > > > > > > > that
    > > > > > > > > I don't understand how to get the text into a stream in
    order
    > to
    > > > be
    > > > > > able
    > > > > > > > to
    > > > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > > > > >
    > > > > > > > > Thanks in advance,
    > > > > > > > >
    > > > > > > > > James
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > Web Form:
    > > > > > > > >
    > > > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > > > > Codebehind="course_new.aspx.vb"
    > > > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > > > > <table cellSpacing="0" cols="3" cellPadding="0"
    width="100%"
    > > > > > > border="0">
    > > > > > > > > <tr>
    > > > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
    > > runat="server"
    > > > > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    > > > runat="server"
    > > > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > > > > BackColor="#F6CD7A"
    > > > > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > > > > Width="80px"></asp:button></td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > <td><asp:textbox id="txtTutorList" runat="server"
    Rows="5"
    > > > > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > > > > runat="server"
    > > > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > > > > </TD></tr>
    > > > > > > > > <tr>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > <td><asp:textbox id="txtOutcome"
    > > > > runat="server"></asp:textbox></td>
    > > > > > > > > <td><asp:button id="cmdAddOutcome" runat="server"
    > Text="Add"
    > > > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > > > > BorderWidth="1px" Width="80px"
    > > > > > > > > CausesValidation="False"></asp:button></td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > > > > GridLines="None"
    > > > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
    > > DataSource="<%#
    > > > > > > > > DatasetOutcomes1 %>">
    > > > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > > > > <Columns>
    > > > > > > > > <asp:TemplateColumn>
    > > > > > > > > <ItemTemplate>
    > > > > > > > > <ul>
    > > > > > > > > <li>
    > > > > > > > > </li>
    > > > > > > > > </ul>
    > > > > > > > > </ItemTemplate>
    > > > > > > > > </asp:TemplateColumn>
    > > > > > > > > <asp:BoundColumn DataField="Name"
    SortExpression="Name"
    > > > > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > > > > SortExpression="DisplayOrder"
    > > > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > </Columns>
    > > > > > > > > </asp:datagrid></td>
    > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > </tr>
    > > > > > > > > <tr>
    > > > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > > > > runat="server"></asp:label></td>
    > > > > > > > > </tr>
    > > > > > > > > </table>
    > > > > > > > > </form>
    > > > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > Code Bind:
    > > > > > > > >
    > > > > > > > > Imports System
    > > > > > > > > Imports System.IO
    > > > > > > > > Imports System.Xml
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > Public Class course_new
    > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > >
    > > > > > > > > #Region " Web Form Designer Generated Code "
    > > > > > > > >
    > > > > > > > > 'This call is required by the Web Form Designer.
    > > > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > > > > > InitializeComponent()
    > > > > > > > > Me.DatasetOutcomes1 = New
    > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > > > > '
    > > > > > > > > 'DatasetOutcomes1
    > > > > > > > > '
    > > > > > > > > Me.DatasetOutcomes1.DataSetName = "DatasetOutcomes"
    > > > > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > > Protected WithEvents lblCourseTitle As
    > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > Protected WithEvents txtCourseTitle As
    > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > Protected WithEvents txtCourseTutor As
    > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > Protected WithEvents txtTutorList As
    > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > Protected WithEvents cmdAdd As
    > > > System.Web.UI.WebControls.Button
    > > > > > > > > Protected WithEvents txtOutcome As
    > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > Protected WithEvents cmdAddOutcome As
    > > > > > > System.Web.UI.WebControls.Button
    > > > > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > Protected WithEvents lblOutcomes As
    > > > > > System.Web.UI.WebControls.Label
    > > > > > > > >
    > > > > > > > > 'NOTE: The following placeholder declaration is required
    > by
    > > > the
    > > > > > Web
    > > > > > > > Form
    > > > > > > > > Designer.
    > > > > > > > > 'Do not delete or move it.
    > > > > > > > > Private designerPlaceholderDeclaration As System.Object
    > > > > > > > >
    > > > > > > > > Private Sub Page_Init(ByVal sender As System.Object,
    ByVal
    > e
    > > > As
    > > > > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > > > > 'CODEGEN: This method call is required by the Web
    Form
    > > > > > Designer
    > > > > > > > > 'Do not modify it using the code editor.
    > > > > > > > > InitializeComponent()
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > #End Region
    > > > > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > > > > Public gstrTableAttribs As String
    > > > > > > > >
    > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,
    ByVal
    > e
    > > > As
    > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > Else
    > > > > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > > > > Dim MyStream As StreamReader
    > > > > > > > >
    > > > > > > > > If str.Length > 0 Then
    > > > > > > > > MyStream = New StreamReader(str)
    > > > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > > > > >
    > > > > > > > > End If
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > > > > '
    > > > > > > > >
    > > > > > > > > End If
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Private Sub UpdateOutcomes()
    > > > > > > > > Me.DataGridOutcomes.DataSource = Me.DatasetOutcomes1
    > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Private Sub cmdAdd_Click(ByVal sender As System.Object,
    > > ByVal
    > > > e
    > > > > As
    > > > > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > > > > >
    > > > > > > > > If InStr(Me.txtTutorList.Text,
    Me.txtCourseTutor.Text)
    > <
    > > 1
    > > > > > Then
    > > > > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > > > > Me.txtTutorList.Text = Me.txtTutorList.Text
    &
    > > ";"
    > > > &
    > > > > > > vbCrLf
    > > > > > > > &
    > > > > > > > > Me.txtCourseTutor.Text
    > > > > > > > > Else
    > > > > > > > > Me.txtTutorList.Text =
    Me.txtCourseTutor.Text
    > > > > > > > > End If
    > > > > > > > > End If
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
    > > System.Object,
    > > > > > ByVal
    > > > > > > e
    > > > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > > > > >
    > > > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > > > > dr.Item("DisplayOrder") =
    > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > > > > >
    > > > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > >
    > > > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > > > > >
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > End Class
    > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    James Norton-Jones Guest

  9. #8

    Default Re: Putting a string onto a stream to be read into a DataGrid

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

    "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    news:3f2a4dd0$0$10785$afc38c87@news.easynet.co.uk. ..
    > It will eventually be written to a SQL DB but each of the data grid items
    > will relate to the new course record. As such the course details need top
    be
    > completed on the form.Once all the course details have been captured the
    > data will be split into several tables. Each of the outcome rows will
    relate
    > to one course record and will be held in a table call tblCourseOutcomes. I
    > did want to get into a situation of create temp record in the DB.
    >
    >
    > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > news:OZvwKnBWDHA.1872@TK2MSFTNGP12.phx.gbl...
    > > Runs on multiple servers - and no Sql Server database to store session
    > state
    > > in.
    > > --
    > > John Saunders
    > > Internet Engineer
    > > [email]john.saunders@surfcontrol.com[/email]
    > >
    > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > > news:3f2a4401$0$10773$afc38c87@news.easynet.co.uk. ..
    > > > Session:
    > > >
    > > > Not able to do that as it will run on multiple servers.
    > > >
    > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > news:uhyw7eBWDHA.1896@TK2MSFTNGP12.phx.gbl...
    > > > > Ok, I don't think I've ever used an updateable XML file yet, so I
    > didn't
    > > > see
    > > > > that. In order to update even a single row, you have to read in the
    > > entire
    > > > > file.
    > > > >
    > > > > Please pardon me for being dense, was your question ever actually
    > > > answered?
    > > > > :-)
    > > > >
    > > > > If I were you, I think I'd store DatasetCourse in Session state. On
    > the
    > > > > other hand, if you're going to be making multiple changes to the
    data
    > > per
    > > > > session, I think I'd keep it in Session, but flush to disk whenever
    a
    > > > change
    > > > > was made. That way, if the session expires (seen as
    > > > Session("DatasetCourse")
    > > > > Is Nothing), then you can re-load it from the disk file (which
    you'll
    > > need
    > > > > to uniquely name, without resorting to the Session ID!)
    > > > > --
    > > > > John Saunders
    > > > > Internet Engineer
    > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > >
    > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > message
    > > > > news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > > > > > DatasetCourse is linked to an xml schema to define the data
    > structure
    > > > and
    > > > > > the data its self is an xml doc. There is no database behind it,
    > hence
    > > > the
    > > > > > need to repopulate from the xml data on postback.
    > > > > >
    > > > > >
    > > > > > Schema:
    > > > > > <?xml version="1.0" encoding="utf-8" ?>
    > > > > > <xs:schema id="DatasetOutcomes"
    > > > > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > > elementFormDefault="qualified"
    > > > > > attributeFormDefault="qualified"
    > > > > >
    > > >
    > xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > > > > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > > > > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > > > > > <xs:complexType>
    > > > > > <xs:choice maxOccurs="unbounded">
    > > > > > <xs:element name="Outcomes">
    > > > > > <xs:complexType>
    > > > > > <xs:sequence>
    > > > > > <xs:element name="Description" type="xs:string"
    minOccurs="0"
    > > />
    > > > > > <xs:element name="DisplayOrder" type="xs:int" minOccurs="0"
    > />
    > > > > > </xs:sequence>
    > > > > > </xs:complexType>
    > > > > > </xs:element>
    > > > > > </xs:choice>
    > > > > > </xs:complexType>
    > > > > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > > > > > <xs:selector xpath=".//mstns:Outcomes" />
    > > > > > <xs:field xpath="mstns:Description" />
    > > > > > </xs:key>
    > > > > > </xs:element>
    > > > > > </xs:schema>
    > > > > >
    > > > > >
    > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > > > > > James,
    > > > > > >
    > > > > > > I'm glad you solved your problem, but I'm wondering how you use
    > > > > > > DatasetCourse on postbacks?
    > > > > > > --
    > > > > > > John Saunders
    > > > > > > Internet Engineer
    > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > >
    > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > > > message
    > > > > > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > > > > > Managed to solve it using:
    > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
    e
    > > As
    > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > 'Put user code to initialize the page here
    > > > > > > > If Not Page.IsPostBack Then
    > > > > > > >
    > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > Else
    > > > > > > > 'Create the XML fragment to be parsed.
    > > > > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > > > > > >
    > > > > > > > If xmlFrag.Length > 0 Then
    > > > > > > >
    > > > > > > > 'Create the XmlNamespaceManager.
    > > > > > > > Dim nt As NameTable = New NameTable
    > > > > > > > Dim nsmgr As XmlNamespaceManager = New
    > > > > > > > XmlNamespaceManager(nt)
    > > > > > > >
    > > > > > > > 'Create the XmlParserContext.
    > > > > > > > Dim context As XmlParserContext = New
    > > > > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > > > > > >
    > > > > > > > 'Create the reader.
    > > > > > > > Dim xmlTR As XmlTextReader = New
    > > > > XmlTextReader(xmlFrag,
    > > > > > > > XmlNodeType.Element, context)
    > > > > > > >
    > > > > > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > > > > > >
    > > > > > > > End If
    > > > > > > > End If
    > > > > > > > End Sub
    > > > > > > >
    > > > > > > >
    > > > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in
    message
    > > > > > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > > > > > Most of the time, your code can follow this pattern:
    > > > > > > > >
    > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal a
    > As
    > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > > myDataSet = GetDataSetSomeHow()
    > > > > > > > > myDataGrid.DataSource = myDataSet
    > > > > > > > > myDataGrid.DataMember = "FirstTable"
    > > > > > > > >
    > > > > > > > > DataBind()
    > > > > > > > > End If
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > > When the page is posted back, the grid (or other controls)
    > will
    > > > > > populate
    > > > > > > > > itself from ViewState.
    > > > > > > > > --
    > > > > > > > > John Saunders
    > > > > > > > > Internet Engineer
    > > > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote
    > in
    > > > > > message
    > > > > > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > > > > > Hi,
    > > > > > > > > >
    > > > > > > > > > Am I trying to hold the data of a DataGrid in a label so
    > that
    > > > when
    > > > > > the
    > > > > > > > > form
    > > > > > > > > > is reposted the DataGrid can be repopulated. The problem I
    > am
    > > > > having
    > > > > > > is
    > > > > > > > > that
    > > > > > > > > > I don't understand how to get the text into a stream in
    > order
    > > to
    > > > > be
    > > > > > > able
    > > > > > > > > to
    > > > > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > > > > > >
    > > > > > > > > > Thanks in advance,
    > > > > > > > > >
    > > > > > > > > > James
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > Web Form:
    > > > > > > > > >
    > > > > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > > > > > Codebehind="course_new.aspx.vb"
    > > > > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > > > > > <table cellSpacing="0" cols="3" cellPadding="0"
    > width="100%"
    > > > > > > > border="0">
    > > > > > > > > > <tr>
    > > > > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
    > > > runat="server"
    > > > > > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    > > > > runat="server"
    > > > > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > > > > > BackColor="#F6CD7A"
    > > > > > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > > > > > Width="80px"></asp:button></td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > <td><asp:textbox id="txtTutorList" runat="server"
    > Rows="5"
    > > > > > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > > > > > runat="server"
    > > > > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > > > > > </TD></tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > <td><asp:textbox id="txtOutcome"
    > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > <td><asp:button id="cmdAddOutcome" runat="server"
    > > Text="Add"
    > > > > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > > > > > BorderWidth="1px" Width="80px"
    > > > > > > > > > CausesValidation="False"></asp:button></td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > > > > > GridLines="None"
    > > > > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
    > > > DataSource="<%#
    > > > > > > > > > DatasetOutcomes1 %>">
    > > > > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > > > > > <Columns>
    > > > > > > > > > <asp:TemplateColumn>
    > > > > > > > > > <ItemTemplate>
    > > > > > > > > > <ul>
    > > > > > > > > > <li>
    > > > > > > > > > </li>
    > > > > > > > > > </ul>
    > > > > > > > > > </ItemTemplate>
    > > > > > > > > > </asp:TemplateColumn>
    > > > > > > > > > <asp:BoundColumn DataField="Name"
    > SortExpression="Name"
    > > > > > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > > > > > SortExpression="DisplayOrder"
    > > > > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > > </Columns>
    > > > > > > > > > </asp:datagrid></td>
    > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > </tr>
    > > > > > > > > > <tr>
    > > > > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > > > > > runat="server"></asp:label></td>
    > > > > > > > > > </tr>
    > > > > > > > > > </table>
    > > > > > > > > > </form>
    > > > > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > Code Bind:
    > > > > > > > > >
    > > > > > > > > > Imports System
    > > > > > > > > > Imports System.IO
    > > > > > > > > > Imports System.Xml
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > Public Class course_new
    > > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > > >
    > > > > > > > > > #Region " Web Form Designer Generated Code "
    > > > > > > > > >
    > > > > > > > > > 'This call is required by the Web Form Designer.
    > > > > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private Sub
    > > > > > > > > > InitializeComponent()
    > > > > > > > > > Me.DatasetOutcomes1 = New
    > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > > > > > '
    > > > > > > > > > 'DatasetOutcomes1
    > > > > > > > > > '
    > > > > > > > > > Me.DatasetOutcomes1.DataSetName =
    "DatasetOutcomes"
    > > > > > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > > > > > >
    > > > > > > > > > End Sub
    > > > > > > > > > Protected WithEvents lblCourseTitle As
    > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > Protected WithEvents txtCourseTitle As
    > > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > Protected WithEvents txtCourseTutor As
    > > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > Protected WithEvents txtTutorList As
    > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > Protected WithEvents cmdAdd As
    > > > > System.Web.UI.WebControls.Button
    > > > > > > > > > Protected WithEvents txtOutcome As
    > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > Protected WithEvents cmdAddOutcome As
    > > > > > > > System.Web.UI.WebControls.Button
    > > > > > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > > Protected WithEvents lblOutcomes As
    > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > >
    > > > > > > > > > 'NOTE: The following placeholder declaration is
    required
    > > by
    > > > > the
    > > > > > > Web
    > > > > > > > > Form
    > > > > > > > > > Designer.
    > > > > > > > > > 'Do not delete or move it.
    > > > > > > > > > Private designerPlaceholderDeclaration As
    System.Object
    > > > > > > > > >
    > > > > > > > > > Private Sub Page_Init(ByVal sender As System.Object,
    > ByVal
    > > e
    > > > > As
    > > > > > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > > > > > 'CODEGEN: This method call is required by the Web
    > Form
    > > > > > > Designer
    > > > > > > > > > 'Do not modify it using the code editor.
    > > > > > > > > > InitializeComponent()
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > #End Region
    > > > > > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > > > > > Public gstrTableAttribs As String
    > > > > > > > > >
    > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,
    > ByVal
    > > e
    > > > > As
    > > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > > Else
    > > > > > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > > > > > Dim MyStream As StreamReader
    > > > > > > > > >
    > > > > > > > > > If str.Length > 0 Then
    > > > > > > > > > MyStream = New StreamReader(str)
    > > > > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > > > > > >
    > > > > > > > > > End If
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > > > > > '
    > > > > > > > > >
    > > > > > > > > > End If
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > Private Sub UpdateOutcomes()
    > > > > > > > > > Me.DataGridOutcomes.DataSource =
    Me.DatasetOutcomes1
    > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > Private Sub cmdAdd_Click(ByVal sender As
    System.Object,
    > > > ByVal
    > > > > e
    > > > > > As
    > > > > > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > > > > > >
    > > > > > > > > > If InStr(Me.txtTutorList.Text,
    > Me.txtCourseTutor.Text)
    > > <
    > > > 1
    > > > > > > Then
    > > > > > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > > > > > Me.txtTutorList.Text =
    Me.txtTutorList.Text
    > &
    > > > ";"
    > > > > &
    > > > > > > > vbCrLf
    > > > > > > > > &
    > > > > > > > > > Me.txtCourseTutor.Text
    > > > > > > > > > Else
    > > > > > > > > > Me.txtTutorList.Text =
    > Me.txtCourseTutor.Text
    > > > > > > > > > End If
    > > > > > > > > > End If
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
    > > > System.Object,
    > > > > > > ByVal
    > > > > > > > e
    > > > > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > > > > > >
    > > > > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > > > > > dr.Item("DisplayOrder") =
    > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > > > > > >
    > > > > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > >
    > > > > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > > > > > >
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > End Class
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    John Saunders Guest

  10. #9

    Default Re: Putting a string onto a stream to be read into a DataGrid

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

    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:unR46SCWDHA.532@TK2MSFTNGP10.phx.gbl...
    > Oh, if there is a Sql Server database, had you considered using the
    > "SQLServer" mode of the <sessionState> element in web.config? I haven't
    > tried it - perhaps it's too slow.
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in message
    > news:3f2a4dd0$0$10785$afc38c87@news.easynet.co.uk. ..
    > > It will eventually be written to a SQL DB but each of the data grid
    items
    > > will relate to the new course record. As such the course details need
    top
    > be
    > > completed on the form.Once all the course details have been captured the
    > > data will be split into several tables. Each of the outcome rows will
    > relate
    > > to one course record and will be held in a table call tblCourseOutcomes.
    I
    > > did want to get into a situation of create temp record in the DB.
    > >
    > >
    > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > news:OZvwKnBWDHA.1872@TK2MSFTNGP12.phx.gbl...
    > > > Runs on multiple servers - and no Sql Server database to store session
    > > state
    > > > in.
    > > > --
    > > > John Saunders
    > > > Internet Engineer
    > > > [email]john.saunders@surfcontrol.com[/email]
    > > >
    > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    message
    > > > news:3f2a4401$0$10773$afc38c87@news.easynet.co.uk. ..
    > > > > Session:
    > > > >
    > > > > Not able to do that as it will run on multiple servers.
    > > > >
    > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > news:uhyw7eBWDHA.1896@TK2MSFTNGP12.phx.gbl...
    > > > > > Ok, I don't think I've ever used an updateable XML file yet, so I
    > > didn't
    > > > > see
    > > > > > that. In order to update even a single row, you have to read in
    the
    > > > entire
    > > > > > file.
    > > > > >
    > > > > > Please pardon me for being dense, was your question ever actually
    > > > > answered?
    > > > > > :-)
    > > > > >
    > > > > > If I were you, I think I'd store DatasetCourse in Session state.
    On
    > > the
    > > > > > other hand, if you're going to be making multiple changes to the
    > data
    > > > per
    > > > > > session, I think I'd keep it in Session, but flush to disk
    whenever
    > a
    > > > > change
    > > > > > was made. That way, if the session expires (seen as
    > > > > Session("DatasetCourse")
    > > > > > Is Nothing), then you can re-load it from the disk file (which
    > you'll
    > > > need
    > > > > > to uniquely name, without resorting to the Session ID!)
    > > > > > --
    > > > > > John Saunders
    > > > > > Internet Engineer
    > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > >
    > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote in
    > > message
    > > > > > news:3f2a3163$0$25422$afc38c87@news.easynet.co.uk. ..
    > > > > > > DatasetCourse is linked to an xml schema to define the data
    > > structure
    > > > > and
    > > > > > > the data its self is an xml doc. There is no database behind it,
    > > hence
    > > > > the
    > > > > > > need to repopulate from the xml data on postback.
    > > > > > >
    > > > > > >
    > > > > > > Schema:
    > > > > > > <?xml version="1.0" encoding="utf-8" ?>
    > > > > > > <xs:schema id="DatasetOutcomes"
    > > > > > > targetNamespace="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > > > elementFormDefault="qualified"
    > > > > > > attributeFormDefault="qualified"
    > > > > > >
    > > > >
    > >
    xmlns="http://http://localhost/1137InsetBookingSystem/DatasetOutcomes.xsd"
    > > > > > > xmlns:mstns="http://tempuri.org/DatasetOutcomes.xsd"
    > > > > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
    > > > > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    > > > > > > <xs:element name="DatasetOutcomes" msdata:IsDataSet="true">
    > > > > > > <xs:complexType>
    > > > > > > <xs:choice maxOccurs="unbounded">
    > > > > > > <xs:element name="Outcomes">
    > > > > > > <xs:complexType>
    > > > > > > <xs:sequence>
    > > > > > > <xs:element name="Description" type="xs:string"
    > minOccurs="0"
    > > > />
    > > > > > > <xs:element name="DisplayOrder" type="xs:int"
    minOccurs="0"
    > > />
    > > > > > > </xs:sequence>
    > > > > > > </xs:complexType>
    > > > > > > </xs:element>
    > > > > > > </xs:choice>
    > > > > > > </xs:complexType>
    > > > > > > <xs:key name="DatasetOutcomesKey1" msdata:PrimaryKey="true">
    > > > > > > <xs:selector xpath=".//mstns:Outcomes" />
    > > > > > > <xs:field xpath="mstns:Description" />
    > > > > > > </xs:key>
    > > > > > > </xs:element>
    > > > > > > </xs:schema>
    > > > > > >
    > > > > > >
    > > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > > > > > news:u1L3ox2VDHA.1600@TK2MSFTNGP09.phx.gbl...
    > > > > > > > James,
    > > > > > > >
    > > > > > > > I'm glad you solved your problem, but I'm wondering how you
    use
    > > > > > > > DatasetCourse on postbacks?
    > > > > > > > --
    > > > > > > > John Saunders
    > > > > > > > Internet Engineer
    > > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > > >
    > > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com> wrote
    in
    > > > > message
    > > > > > > > news:3f28fa69$0$25429$afc38c87@news.easynet.co.uk. ..
    > > > > > > > > Managed to solve it using:
    > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,
    ByVal
    > e
    > > > As
    > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > >
    > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > Else
    > > > > > > > > 'Create the XML fragment to be parsed.
    > > > > > > > > Dim xmlFrag As String = Me.lblOutcomes.Text
    > > > > > > > >
    > > > > > > > > If xmlFrag.Length > 0 Then
    > > > > > > > >
    > > > > > > > > 'Create the XmlNamespaceManager.
    > > > > > > > > Dim nt As NameTable = New NameTable
    > > > > > > > > Dim nsmgr As XmlNamespaceManager = New
    > > > > > > > > XmlNamespaceManager(nt)
    > > > > > > > >
    > > > > > > > > 'Create the XmlParserContext.
    > > > > > > > > Dim context As XmlParserContext = New
    > > > > > > > > XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None)
    > > > > > > > >
    > > > > > > > > 'Create the reader.
    > > > > > > > > Dim xmlTR As XmlTextReader = New
    > > > > > XmlTextReader(xmlFrag,
    > > > > > > > > XmlNodeType.Element, context)
    > > > > > > > >
    > > > > > > > > Me.DatasetCourse.ReadXml(xmlTR)
    > > > > > > > >
    > > > > > > > > End If
    > > > > > > > > End If
    > > > > > > > > End Sub
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "John Saunders" <john.saunders@surfcontrol.com> wrote in
    > message
    > > > > > > > > news:OPTf5I1VDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > > > > > > > > Most of the time, your code can follow this pattern:
    > > > > > > > > >
    > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object, ByVal
    a
    > > As
    > > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > > > myDataSet = GetDataSetSomeHow()
    > > > > > > > > > myDataGrid.DataSource = myDataSet
    > > > > > > > > > myDataGrid.DataMember = "FirstTable"
    > > > > > > > > >
    > > > > > > > > > DataBind()
    > > > > > > > > > End If
    > > > > > > > > > End Sub
    > > > > > > > > >
    > > > > > > > > > When the page is posted back, the grid (or other controls)
    > > will
    > > > > > > populate
    > > > > > > > > > itself from ViewState.
    > > > > > > > > > --
    > > > > > > > > > John Saunders
    > > > > > > > > > Internet Engineer
    > > > > > > > > > [email]john.saunders@surfcontrol.com[/email]
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > > "James Norton-Jones" <james.norton-jones@stopford.com>
    wrote
    > > in
    > > > > > > message
    > > > > > > > > > news:3f28da96$0$25420$afc38c87@news.easynet.co.uk. ..
    > > > > > > > > > > Hi,
    > > > > > > > > > >
    > > > > > > > > > > Am I trying to hold the data of a DataGrid in a label so
    > > that
    > > > > when
    > > > > > > the
    > > > > > > > > > form
    > > > > > > > > > > is reposted the DataGrid can be repopulated. The problem
    I
    > > am
    > > > > > having
    > > > > > > > is
    > > > > > > > > > that
    > > > > > > > > > > I don't understand how to get the text into a stream in
    > > order
    > > > to
    > > > > > be
    > > > > > > > able
    > > > > > > > > > to
    > > > > > > > > > > use DataSetOutcomes1.ReadXML(MyStream).
    > > > > > > > > > >
    > > > > > > > > > > Thanks in advance,
    > > > > > > > > > >
    > > > > > > > > > > James
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > Web Form:
    > > > > > > > > > >
    > > > > > > > > > > <%@ Page Language="vb" AutoEventWireup="false"
    > > > > > > > > > > Codebehind="course_new.aspx.vb"
    > > > > > > > > > > Inherits="_1137InsetBookingSystem.course_new"%>
    > > > > > > > > > > <!-- #INCLUDE file="headeraspx.inc" -->
    > > > > > > > > > > <!-- #INCLUDE file="tableheader.inc" -->
    > > > > > > > > > > <form id="FormNewCourse" method="post" runat="server">
    > > > > > > > > > > <table cellSpacing="0" cols="3" cellPadding="0"
    > > width="100%"
    > > > > > > > > border="0">
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td vAlign="top"><asp:label id="lblCourseTitle"
    > > > > runat="server"
    > > > > > > > > > > Font-Bold="True">Course Title</asp:label></td>
    > > > > > > > > > > <td><asp:textbox id="txtCourseTitle"
    > > > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td colSpan="3"><asp:label id="lblCourseTutorList"
    > > > > > runat="server"
    > > > > > > > > > > Font-Bold="True">Course Tutor(s)</asp:label></td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td vAlign="top">&nbsp;</td>
    > > > > > > > > > > <td><asp:textbox id="txtCourseTutor"
    > > > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > > <td><asp:button id="cmdAdd" runat="server" Text="Add"
    > > > > > > > > > BackColor="#F6CD7A"
    > > > > > > > > > > BorderStyle="Solid" BorderWidth="1px"
    > > > > > > > > > > Width="80px"></asp:button></td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > <td><asp:textbox id="txtTutorList" runat="server"
    > > Rows="5"
    > > > > > > > > > > TextMode="MultiLine"></asp:textbox></td>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td colSpan="3"><asp:label id="lblLearningOutcomes"
    > > > > > > runat="server"
    > > > > > > > > > > Font-Bold="True">Learning Outcomes</asp:label></td>
    > > > > > > > > > > </TD></tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > <td><asp:textbox id="txtOutcome"
    > > > > > > runat="server"></asp:textbox></td>
    > > > > > > > > > > <td><asp:button id="cmdAddOutcome" runat="server"
    > > > Text="Add"
    > > > > > > > > > > BackColor="#F6CD7A" BorderStyle="Solid"
    > > > > > > > > > > BorderWidth="1px" Width="80px"
    > > > > > > > > > > CausesValidation="False"></asp:button></td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > <td><asp:datagrid id=DataGridOutcomes runat="server"
    > > > > > > > GridLines="None"
    > > > > > > > > > > AutoGenerateColumns="False" DataMember="Outcomes"
    > > > > DataSource="<%#
    > > > > > > > > > > DatasetOutcomes1 %>">
    > > > > > > > > > > <HeaderStyle Font-Bold="True"></HeaderStyle>
    > > > > > > > > > > <Columns>
    > > > > > > > > > > <asp:TemplateColumn>
    > > > > > > > > > > <ItemTemplate>
    > > > > > > > > > > <ul>
    > > > > > > > > > > <li>
    > > > > > > > > > > </li>
    > > > > > > > > > > </ul>
    > > > > > > > > > > </ItemTemplate>
    > > > > > > > > > > </asp:TemplateColumn>
    > > > > > > > > > > <asp:BoundColumn DataField="Name"
    > > SortExpression="Name"
    > > > > > > > > > > HeaderText="Name"></asp:BoundColumn>
    > > > > > > > > > > <asp:BoundColumn DataField="DisplayOrder"
    > > > > > > > > > > SortExpression="DisplayOrder"
    > > > > > > > > HeaderText="DisplayOrder"></asp:BoundColumn>
    > > > > > > > > > > <asp:ButtonColumn Text="Delete"
    > > > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > > > <asp:ButtonColumn Text="Edit"
    > > > > > > > > > > ButtonType="PushButton"></asp:ButtonColumn>
    > > > > > > > > > > </Columns>
    > > > > > > > > > > </asp:datagrid></td>
    > > > > > > > > > > <td>&nbsp;</td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > <tr>
    > > > > > > > > > > <td colSpan="3"><asp:label id="lblOutcomes"
    > > > > > > > > > > runat="server"></asp:label></td>
    > > > > > > > > > > </tr>
    > > > > > > > > > > </table>
    > > > > > > > > > > </form>
    > > > > > > > > > > <!-- #INCLUDE file="tablefooter.inc" -->
    > > > > > > > > > > <!-- #INCLUDE file="footer.inc" -->
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > Code Bind:
    > > > > > > > > > >
    > > > > > > > > > > Imports System
    > > > > > > > > > > Imports System.IO
    > > > > > > > > > > Imports System.Xml
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > Public Class course_new
    > > > > > > > > > > Inherits System.Web.UI.Page
    > > > > > > > > > >
    > > > > > > > > > > #Region " Web Form Designer Generated Code "
    > > > > > > > > > >
    > > > > > > > > > > 'This call is required by the Web Form Designer.
    > > > > > > > > > > <System.Diagnostics.DebuggerStepThrough()> Private
    Sub
    > > > > > > > > > > InitializeComponent()
    > > > > > > > > > > Me.DatasetOutcomes1 = New
    > > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > > > System.ComponentModel.ISupportInitialize).BeginIni t()
    > > > > > > > > > > '
    > > > > > > > > > > 'DatasetOutcomes1
    > > > > > > > > > > '
    > > > > > > > > > > Me.DatasetOutcomes1.DataSetName =
    > "DatasetOutcomes"
    > > > > > > > > > > Me.DatasetOutcomes1.Locale = New
    > > > > > > > > > > System.Globalization.CultureInfo("en-GB")
    > > > > > > > > > > CType(Me.DatasetOutcomes1,
    > > > > > > > > > > System.ComponentModel.ISupportInitialize).EndInit( )
    > > > > > > > > > >
    > > > > > > > > > > End Sub
    > > > > > > > > > > Protected WithEvents lblCourseTitle As
    > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > > Protected WithEvents txtCourseTitle As
    > > > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > > Protected WithEvents txtCourseTutor As
    > > > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > > Protected WithEvents txtTutorList As
    > > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > > Protected WithEvents cmdAdd As
    > > > > > System.Web.UI.WebControls.Button
    > > > > > > > > > > Protected WithEvents txtOutcome As
    > > > > > > > System.Web.UI.WebControls.TextBox
    > > > > > > > > > > Protected WithEvents cmdAddOutcome As
    > > > > > > > > System.Web.UI.WebControls.Button
    > > > > > > > > > > Protected WithEvents lblCourseTutorList As
    > > > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > > Protected WithEvents lblLearningOutcomes As
    > > > > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > > Protected WithEvents DataGridOutcomes As
    > > > > > > > > > > System.Web.UI.WebControls.DataGrid
    > > > > > > > > > > Protected WithEvents DatasetOutcomes1 As
    > > > > > > > > > > _1137InsetBookingSystem.DatasetOutcomes
    > > > > > > > > > > Protected WithEvents lblOutcomes As
    > > > > > > > System.Web.UI.WebControls.Label
    > > > > > > > > > >
    > > > > > > > > > > 'NOTE: The following placeholder declaration is
    > required
    > > > by
    > > > > > the
    > > > > > > > Web
    > > > > > > > > > Form
    > > > > > > > > > > Designer.
    > > > > > > > > > > 'Do not delete or move it.
    > > > > > > > > > > Private designerPlaceholderDeclaration As
    > System.Object
    > > > > > > > > > >
    > > > > > > > > > > Private Sub Page_Init(ByVal sender As System.Object,
    > > ByVal
    > > > e
    > > > > > As
    > > > > > > > > > > System.EventArgs) Handles MyBase.Init
    > > > > > > > > > > 'CODEGEN: This method call is required by the
    Web
    > > Form
    > > > > > > > Designer
    > > > > > > > > > > 'Do not modify it using the code editor.
    > > > > > > > > > > InitializeComponent()
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > #End Region
    > > > > > > > > > > Public gstrTableTitle As String = "Create Course"
    > > > > > > > > > > Public gstrTableAttribs As String
    > > > > > > > > > >
    > > > > > > > > > > Private Sub Page_Load(ByVal sender As System.Object,
    > > ByVal
    > > > e
    > > > > > As
    > > > > > > > > > > System.EventArgs) Handles MyBase.Load
    > > > > > > > > > > 'Put user code to initialize the page here
    > > > > > > > > > > If Not Page.IsPostBack Then
    > > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > > > Else
    > > > > > > > > > > Dim str As String = Me.lblOutcomes.Text
    > > > > > > > > > > Dim MyStream As StreamReader
    > > > > > > > > > >
    > > > > > > > > > > If str.Length > 0 Then
    > > > > > > > > > > MyStream = New StreamReader(str)
    > > > > > > > > > > Me.DatasetOutcomes1.ReadXml(MyStream)
    > > > > > > > > > >
    > > > > > > > > > > End If
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > > 'Me.DatasetOutcomes1.GetXml()
    > > > > > > > > > > '
    > > > > > > > > > >
    > > > > > > > > > > End If
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > Private Sub UpdateOutcomes()
    > > > > > > > > > > Me.DataGridOutcomes.DataSource =
    > Me.DatasetOutcomes1
    > > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > Private Sub cmdAdd_Click(ByVal sender As
    > System.Object,
    > > > > ByVal
    > > > > > e
    > > > > > > As
    > > > > > > > > > > System.EventArgs) Handles cmdAdd.Click
    > > > > > > > > > >
    > > > > > > > > > > If InStr(Me.txtTutorList.Text,
    > > Me.txtCourseTutor.Text)
    > > > <
    > > > > 1
    > > > > > > > Then
    > > > > > > > > > > If Me.txtTutorList.Text.Length > 0 Then
    > > > > > > > > > > Me.txtTutorList.Text =
    > Me.txtTutorList.Text
    > > &
    > > > > ";"
    > > > > > &
    > > > > > > > > vbCrLf
    > > > > > > > > > &
    > > > > > > > > > > Me.txtCourseTutor.Text
    > > > > > > > > > > Else
    > > > > > > > > > > Me.txtTutorList.Text =
    > > Me.txtCourseTutor.Text
    > > > > > > > > > > End If
    > > > > > > > > > > End If
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > Private Sub cmdAddOutcome_Click(ByVal sender As
    > > > > System.Object,
    > > > > > > > ByVal
    > > > > > > > > e
    > > > > > > > > > > As System.EventArgs) Handles cmdAddOutcome.Click
    > > > > > > > > > > Dim dr As DatasetOutcomes.OutcomesRow
    > > > > > > > > > >
    > > > > > > > > > > dr = Me.DatasetOutcomes1.Outcomes.NewRow()
    > > > > > > > > > > dr.Item("Name") = Me.txtOutcome.Text
    > > > > > > > > > > dr.Item("DisplayOrder") =
    > > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count
    > > > > > > > > > > 'DatasetOutcomes1.Outcomes.Rows.InsertAt(dr,
    > > > > > > > > > > Me.DatasetOutcomes1.Outcomes.Rows.Count)
    > > > > > > > > > >
    > > > > > > > > > > DatasetOutcomes1.Outcomes.Rows.Add(dr)
    > > > > > > > > > > Me.DataGridOutcomes.DataBind()
    > > > > > > > > > >
    > > > > > > > > > > Me.lblOutcomes.Text = Me.DatasetOutcomes1.GetXml
    > > > > > > > > > >
    > > > > > > > > > > End Sub
    > > > > > > > > > >
    > > > > > > > > > > End Class
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > > >
    > > > > > > > > >
    > > > > > > > > >
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    James Norton-Jones Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139