2 Replies - 8876 Views - Last Post: 16 February 2013 - 11:22 AM

#1 xoxokryssie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-February 13

CREATE AN XML FILE VIA BUTTON FROM A DROP DOWN

Posted 16 February 2013 - 11:16 AM

Hello! I am currently an IS major taking a few programming classes, so I'm pretty new to this. Anyways, I am stuck on this pat of my assignment. Here are the instructions:

"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 :)

Is This A Good Question/Topic? 0
  • +

Replies To: CREATE AN XML FILE VIA BUTTON FROM A DROP DOWN

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5529
  • View blog
  • Posts: 11,839
  • Joined: 02-June 10

Re: CREATE AN XML FILE VIA BUTTON FROM A DROP DOWN

Posted 16 February 2013 - 11:17 AM

If you are *this* lost and confused you need to go to your instructor.
They need to understand that they are not doing a good job of explaining the material, or that you just need some one-on-one time.

Programming is not a course to bluff through and hope it will all click into place in 3 weeks. Later lessons build on earlier one. 3 weeks from now you will be so lost you might not catch up.
Was This Post Helpful? 0
  • +
  • -

#3 xoxokryssie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 16-February 13

Re: CREATE AN XML FILE VIA BUTTON FROM A DROP DOWN

Posted 16 February 2013 - 11:22 AM

Thanks for your help...I think? But I have figured it out!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1