Swati M

Swati M

  • NA
  • 11
  • 0

To bind the xmldatasource

Aug 1 2008 6:43 AM

Hello,

Everybody...i have created a datagrid with xml datasource as bounded now i have 2nd page where in which i have labels now i want that xmldatasource record should be bounded to the 2nd page particular label and should  display that record in that label ..So please help me out!!!

Thanku.

Here is the code for the 2 pages.

This is the 1st page sourcecode with xml datasource connected

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sam_coll_order.aspx.cs" Inherits="test_details"

Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Untitled Page</title>

<link href="gridview.css" rel="stylesheet" type="text/css" />

<%--<script language="JavaScript" type="text/javascript">

function printit(){

if (window.print) {

window.print() ;

}

else if (document.all) {

var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0

CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

document.body.insertAdjacentHTML('beforeEnd', WebBrowser);

WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box

WebBrowser1.outerHTML = "";

}

}

</script>--%>

</head>

<body>

<form id="form1" runat="server">

<div>

<table style="width: 190px; height: 480px;" class="table1">

<tr>

<td style="height: 1px; width: 201px; background-color: peachpuff;" align="center"

valign="middle">

<asp:Label ID="Label1" runat="server" Text="Sample Collection Order" CssClass="PageHeading"

Width="176px"></asp:Label></td>

</tr>

<tr>

<td align="left" style="width: 201px; height: 1px" valign="middle">

<asp:Label ID="Label15" runat="server" BackColor="White" BorderColor="Black" BorderWidth="1px"

Font-Size="10px" Height="10px" Width="10px"></asp:Label>&nbsp;

<asp:Label ID="Label12" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10px"

Text="STAT"></asp:Label>

<asp:Label ID="Label14" runat="server" BackColor="Red" BorderColor="Black" BorderWidth="1px"

Font-Size="10px" Height="10px" Width="10px"></asp:Label>&nbsp;

<asp:Label ID="Label13" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="10px"

Height="10px" Text="ROUTINE" Width="1px"></asp:Label>

</td>

</tr>

<tr>

<td align="right" style="width: 201px; height: 300px;" valign="top">

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CssClass="grid-view"

OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated" AllowPaging="True"

Width="190px" PageSize="5" CaptionAlign="Left" CellPadding="4" ForeColor="#333333"

GridLines="None" EmptyDataText="Empty" EnableSortingAndPagingCallbacks="True"

Height="349px" OnRowCommand="GridView1_RowCommand" OnSelectedIndexChanged="GridView1_SelectedIndexChanged1" OnSelectedIndexChanging="GridView1_SelectedIndexChanging">

<HeaderStyle CssClass="header" BackColor="#507CD1" Font-Bold="True" ForeColor="White"

Height="30px" />

<AlternatingRowStyle CssClass="alternate" BackColor="White" />

<RowStyle CssClass="normal" BackColor="#EFF3FB" />

<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="30px"

VerticalAlign="Bottom" />

<EditRowStyle BackColor="#2461BF" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" VerticalAlign="Bottom" />

<EmptyDataRowStyle CssClass="emptyRow" />

<Columns>

<asp:HyperLinkField HeaderText="Ind">

<ItemStyle BorderColor="Black" BorderWidth="1px" Wrap="True" />

<HeaderStyle BorderColor="Black" BorderWidth="1px" />

<FooterStyle BorderColor="Black" BorderWidth="1px" />

</asp:HyperLinkField>

<asp:BoundField HeaderText="MRN" DataField="MRN">

<ItemStyle BorderColor="Black" BorderWidth="1px" Wrap="True" />

<HeaderStyle BorderColor="Black" BorderWidth="1px" />

<FooterStyle BorderColor="Black" BorderWidth="1px" />

</asp:BoundField>

<asp:BoundField HeaderText="Name" DataField="Name">

<ItemStyle BorderColor="Black" BorderWidth="1px" Wrap="True" />

<HeaderStyle BorderColor="Black" BorderWidth="1px" />

<FooterStyle BorderColor="Black" BorderWidth="1px" />

</asp:BoundField>

<asp:HyperLinkField HeaderText="Sample Detail" NavigateUrl="~/sam_details.aspx" Text="view">

<ItemStyle BorderColor="Black" BorderWidth="1px" Wrap="True"/>

<HeaderStyle BorderColor="Black" BorderWidth="1px" />

<FooterStyle BorderColor="Black" BorderWidth="1px" />

</asp:HyperLinkField>

</Columns>

<EmptyDataTemplate>

</EmptyDataTemplate>

<PagerSettings Visible="False" />

</asp:GridView>

<asp:Panel ID="Panel2" runat="server" Height="20px" Width="180px">

<asp:LinkButton ID="LinkButton1" runat="server" Font-Bold="False" OnClick="LinkButton1_Click"

CssClass="links">First</asp:LinkButton>&nbsp; &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" Font-Bold="False" OnClick="LinkButton2_Click"

Visible="False" CssClass="links">Previous</asp:LinkButton>

&nbsp;&nbsp;

<asp:LinkButton ID="LinkButton3" runat="server" Font-Bold="False" Font-Size="10px"

OnClick="LinkButton3_Click" CssClass="links">Next</asp:LinkButton>

&nbsp;&nbsp;

<asp:LinkButton ID="LinkButton4" runat="server" Font-Bold="False" OnClick="LinkButton4_Click"

CssClass="links">Last</asp:LinkButton></asp:Panel><hr />

</td>

</tr>

<tr>

<td align="right" style="width: 201px; height: 1px;" valign="top">

<asp:Panel ID="Panel1" runat="server" Height="20px" Width="125px">

<asp:Button ID="Button1" runat="server" Text="Close" Font-Size="9px" Width="89px"

Height="40px" Font-Names="Verdana" OnClientClick="window.opener=null; window.close();" /></asp:Panel>

</td>

</tr>

</table>

<%--<div>

<asp:Button ID="Button2" runat="server" onClick="printit()" Text="Print" />&nbsp;</div>

<br />--%>

</div>

</form>

</body>

</html>

SourceCode for next page to which 1st page is connected.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sam_details.aspx.cs" Inherits="sam_coll_det" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitled Page</title>

<link href="gridview.css" rel="stylesheet" type="text/css" />

</head>

<body>

<form id="form1" runat="server">

&nbsp;<div>

<table class="table1" style="width: 190px; height: 480px;">

<tr>

<td align="center" colspan="4" style="background-color: peachpuff; height: 18px;">

<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="False" Text="Sample Details"

CssClass="PageHeading" Width="107px"></asp:Label></td>

</tr>

<tr>

<td style="width: 41px; height: 20px;" rowspan="1" align="left" valign="top">

<asp:Label ID="Label2" runat="server" Font-Bold="False" Text="MRN :" CssClass="tableLabels"></asp:Label></td>

<td align="left" colspan="1" rowspan="1" style="width: 31px; word-wrap: break-word;

height: 20px" valign="top">

<asp:Label ID="Label4" runat="server" Text='<%# XPath("sampledetails/data[@MRN]=")%>' Width="67px" CssClass="tableLabels"></asp:Label></td>

<td colspan="1" align="right" rowspan="3" valign="top">

<asp:Image ID="Image1" runat="server" Height="60px" ImageAlign="Baseline" ImageUrl="~/images/Sunset.jpg"

Width="50px" /></td>

</tr>

<tr>

<td rowspan="1" style="width: 41px; height: 20px" valign="top">

<asp:Label ID="Label3" runat="server" Font-Bold="False" Text="Name :" Width="8px"

CssClass="tableLabels"></asp:Label></td>

<td align="left" colspan="1" rowspan="1" style="width: 31px; word-wrap: break-word;

height: 20px" valign="top">

<asp:Label ID="Label7" runat="server" Width="63px" EnableViewState="False" OnLoad="Label7_Load"

CssClass="tableLabels">Basu</asp:Label></td>

</tr>

<tr>

<td rowspan="1" style="width: 41px; height: 20px" align="left" valign="top">

<asp:Label ID="Label12" runat="server" Font-Bold="False" Text="Doctor :" CssClass="tableLabels"></asp:Label></td>

<td align="left" colspan="1" rowspan="1" style="width: 31px; word-wrap: break-word;

height: 20px" valign="top">

<asp:Label ID="Label8" runat="server" Text="Swati M" Width="62px" CssClass="tableLabels"></asp:Label></td>

</tr>

<tr>

<td align="left" rowspan="1" style="width: 41px; height: 20px" valign="top">

<asp:Label ID="Label5" runat="server" Font-Bold="False" Text="OrderDate :" Width="27px"

CssClass="tableLabels"></asp:Label></td>

<td align="left" colspan="2" rowspan="1" style="height: 20px" valign="top">

<asp:Label ID="Label9" runat="server" CssClass="tableLabels" Text="23/7/200811:52AM"></asp:Label></td>

</tr>

<tr>

<td rowspan="1" style="width: 41px; height: 20px" align="left" valign="top">

<asp:Label ID="Label6" runat="server" Font-Bold="False" Text="Priority :" CssClass="tableLabels"></asp:Label></td>

<td align="left" colspan="2" rowspan="1" style="height: 20px" valign="top">

<asp:Label ID="Label11" runat="server" Text="STAT/ROUTINE" CssClass="tableLabels"></asp:Label></td>

</tr>

<tr>

<td align="left" colspan="3" style="height: 19px">

<%--<div id="scrollBar" style="overflow:scroll;width:190px">--%>

<asp:GridView Width="190px" ID="GridView1" runat="server" AutoGenerateColumns="False"

DataSourceID="XmlDataSource1" CssClass="grid-view" OnDataBound="Page_Load" CellPadding="4"

ForeColor="#333333" GridLines="None" OnRowCommand="GridView1_RowCommand">

<Columns>

<asp:BoundField DataField="Sample_Type" HeaderText="Sample" SortExpression="Sample_Type">

<ItemStyle BorderColor="Black" BorderWidth="1px" />

</asp:BoundField>

<asp:BoundField DataField="Container_Data" HeaderText="Container" SortExpression="Container_Data">

<ItemStyle BorderColor="Black" BorderWidth="1px" />

<HeaderStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />

</asp:BoundField>

<asp:HyperLinkField HeaderText="Test" NavigateUrl="~/test_details.aspx" Text="view">

<ItemStyle BorderColor="Black" BorderWidth="1px" />

<HeaderStyle BorderColor="Black" BorderWidth="1px" />

</asp:HyperLinkField>

</Columns>

<HeaderStyle CssClass="header" BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

<AlternatingRowStyle CssClass="alternate" BackColor="White" />

<RowStyle CssClass="normal" BackColor="#EFF3FB" />

<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

<EditRowStyle BackColor="#2461BF" />

<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

</asp:GridView>

&nbsp;<%--</div>--%>

</td>

</tr>

<tr>

<td colspan="3" style="height: 42px" align="right">

<asp:Button ID="Button1" runat="server" Font-Size="9px" Text="Generate Barcode" Width="100px"

OnClick="Button1_Click" Height="40px" Font-Names="Verdana" />&nbsp;

<asp:Button ID="Button4" runat="server" Font-Names="Verdana" Font-Size="9px" Height="40px"

OnClick="Button4_Click" Text="Back" Width="60px" /></td>

</tr>

<tr>

<td colspan="3" style="height: 41px" align="right">

<asp:Button ID="Button2" runat="server" Font-Names="Verdana" Font-Size="9px" Text="Conform Sample"

Width="100px" Height="40px" OnClick="Button2_Click" />&nbsp;

<asp:Button ID="Button3" runat="server" Font-Names="Verdana" Font-Size="9px" Text="Close"

Height="40px" Width="60px" OnClick="Button3_Click" OnClientClick="window.opener=null; window.close(); " /></td>

</tr>

</table>

<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/SampleDetails.xml" />

<br />

</div>

</form>

</body>

</html>