"Provide a button that uses the DropDownList selection to create an xml file. The xml file contains all details of the record selected from the dropdownlist(you can decide the structure of the xml file). The xml file is then saved to
your web application folder."
Here is the code that is in my .aspx file called "assignment2p1.aspx"
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="assignment2p1.aspx.cs" Inherits="assignment2p1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Assignment 2</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList
ID="ddlNames"
DataSourceId="srcNames"
DataTextField="CAT_NA"
DataValueField="CAT_ID"
runat="server">
</asp:DropDownList>
<asp:Button
id="btnSelect"
Text="Select"
ToolTip="Select Name"
Runat="server" />
<hr />
<asp:GridView
id="grdCategory"
DataSourceID="srcCategory"
Runat="server" />
<asp:SqlDataSource
id="srcNames"
connectionString="<%$ ConnectionStrings:eBizDatabase %>"
SelectCommand="SELECT CAT_NA, CAT_ID FROM CATEGORY_TBL"
Runat="server" />
<asp:SqlDataSource
id="srcCategory"
DataSourceMode="DataSet"
ConnectionString="<%$ ConnectionStrings:eBizDatabase %>"
SelectCommand="SELECT CAT_NA as Category_Name, CAT_DESCP AS Category_Description FROM CATEGORY_TBL
WHERE CAT_ID=@CAT_ID"
Runat="server">
<SelectParameters>
<asp:ControlParameter
Name="CAT_ID"
Type="int32"
ControlID="ddlNames" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<p>
<asp:Button
ID="Button1"
runat="server"
Text="Button" />
</p>
</form>
</body>
</html>
[/cod]
And here is the code my my .cs page called "xmldb.cs"
[code]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Xml.Xsl;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// Summary description for xmldb
/// </summary>
public class xmldb
{
string conString = WebConfigurationManager.ConnectionStrings["ebizDatabase"].ConnectionString;
public xmldb()
{
}
public void xmlFromDb()
{
SqlConnection con = new SqlConnection(conString);
con.Open();
DataSet moviesDS = new DataSet("CatDataSet");
SqlDataAdapter moviesDA = new SqlDataAdapter("SELECT * FROM CAT_NA", con);
moviesDA.Fill(moviesDS, "Category");
SqlDataAdapter movieCategoryDA = new SqlDataAdapter("SELECT * FROM CAT_DESCP", con);
movieCategoryDA.Fill(moviesDS, "Description");
con.Close();
}
}
I am not 100% sure what to do from here. I am getting no errors, I just can't figure out how to stat with the button click. I know I obviously need to create one, but where should it go? Also, I was told by a classmate to create this separate .cs file, but I am wondering if this code should actually go in the "assignment2p1.aspx.cs" file.
I hope someone can help me, I have been stuck on this part for a while!
Thanks! And keep in mind, I'm kind of a newbie
Sorry I kind of messed up how the code is supposed to be displayed but other than that everything is showing up right

New Topic/Question
Reply


MultiQuote




|