All pastes #272988 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-12-09 13:58 UTC
rendered paste body
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class CreateLoungeControl : System.Web.UI.UserControl
{
    DataSet data;
    string loungeID;

    public string LoungeID
    {
        get { return loungeID; }
        set
        {
            loungeID = value;
            data = Database.GetDataVal("Lounge", "Lounge_ID", loungeID);
            if (data.Tables[0].Rows.Count == 0)
            {
                DataRow newLounge = data.Tables[0].NewRow();
                newLounge["Lounge_ID"] = loungeID;
                newLounge["Owner_ID"] = Membership.GetUser().ToString();
                data.Tables[0].Rows.Add(newLounge);
            }
        }
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        LoungeInfoView.DataSource = data;
        LoungeInfoView.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
        data.Tables[0].Rows[0]["Name"] = ((TextBox)LoungeInfoView.FindControl("Name")).Text;
        data.Tables[0].Rows[0]["Description"] = ((TextBox)LoungeInfoView.FindControl("Desc")).Text;
        data.Tables[0].Rows[0]["Category"] = ((ListBox)LoungeInfoView.FindControl("Category")).SelectedItem.ToString();

        if (Page.IsPostBack)
        {
            int fileLen;
            if (((FileUpload)LoungeInfoView.FindControl("PictureUpload")).HasFile)
            {
                String fileExtension =
                    System.IO.Path.GetExtension(((FileUpload)LoungeInfoView.FindControl("PictureUpload")).FileName).ToLower();
                String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg", ".bmp" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (fileExtension == allowedExtensions[i])
                    {
                        // Get the length of the file.
                        fileLen = ((FileUpload)LoungeInfoView.FindControl("PictureUpload")).PostedFile.ContentLength;

                        // Create a byte array to hold the contents of the file.
                        byte[] input = new byte[fileLen];
                        input = ((FileUpload)LoungeInfoView.FindControl("PictureUpload")).FileBytes;
                        data.Tables[0].Rows[0]["Picture"] = input;
                    }
                }
            }

            Database.UpdateData("Lounge", "Lounge_ID", data.Tables[0].Rows[0]["Lounge_ID"].ToString(), data);
            //string link = "~/Lounge/Lounge.aspx?id=" + data.Tables[0].Rows[0]["Lounge_ID"].ToString();
            string link = "http://www.yahoo.com";
            Response.Redirect(link);
        }
    }
}