<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="C#" runat="server">
void SubmitBtn_Click(Object sender, EventArgs e)
{
// Set the stream connection info to the XML data file
FileStream fs = new FileStream(Server.MapPath("pubcols.xml"), FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
DataSet ds = new DataSet();
ds.ReadXml(reader);
fs.Close();
// Enumerate through the "Web" table and convert URL to an HREF tag
DataTable myTable = ds.Tables["RECORD"];
DataColumn myColumn = myTable.Columns["Web"];
string sURL = "";
foreach (DataRow myRow in myTable.Rows)
{
sURL = myRow[myColumn].ToString();
myRow[myColumn] = "<a href=\"http://" + sURL + "\">" + sURL + "</a>";
}
// Apply SORT BY selection to dataview
DataView myDataView = ds.Tables["RECORD"].DefaultView;
myDataView.Sort = listBox1.SelectedItem.Text;
// Bind datagrid with dataset values
MyDataGrid.DataSource = myDataView;
MyDataGrid.DataBind();
}
</script>
...HTML tags...
<asp:ListBox id="listBox1" Rows="1" runat="server">
<asp:ListItem Value="1" Text="School"/>
<asp:ListItem Value="2" Text="City"/>
<asp:ListItem Value="3" Text="Nickname"/>
<asp:ListItem Value="4" Text="Web"/>
</asp:ListBox>
...HTML tags...
<asp:Button id="Button1"
Text="Run Query"
OnClick="SubmitBtn_Click"
runat="server"/>
...HTML tags...
<asp:DataGrid id="MyDataGrid"
Width="360"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="10pt"
GridLines="Horizontal"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
runat="server">
<HeaderStyle BackColor="#00aaaa" Font-Bold="true">
</HeaderStyle>
</asp:DataGrid>
...HTML tags...
|