• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

c# event wont fire asp.net 2.0



protected void btnCopy_Click(object sender, System.EventArgs e)  <------  Why wont this event fire?

Here is the sourse code:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using huntn.classes;
using System.Data.OleDb;

public partial class catalog_cat_admin_add_itemsnew : System.Web.UI.Page
{
            string dbPath = "../../data/mlm.mdb";            
            DateTime nDate = DateTime.Now;
            string lowResName, highResName, insertCmd;
            System.Data.OleDb.OleDbConnection conn = new OleDbConnection();
        System.Data.OleDb.OleDbCommand cmd = new OleDbCommand();
            huntn.classes.inc msg = new inc();

            TextBox retailText = new TextBox();
            TextBox dropShipText = new TextBox();
            TextBox costText = new TextBox();
            TextBox partNumText = new TextBox();
            CheckBox disconText = new CheckBox();
            CheckBox deleteText = new CheckBox();
            TextBox spec1Text = new TextBox();
            TextBox spec2Text = new TextBox();
            TextBox manText = new TextBox();
            TextBox vendText = new TextBox();            
            TextBox quantText = new TextBox();
            TextBox bbrText = new TextBox();
            TextBox qvText = new TextBox();

            string  partNumber, manNumber, vendNumber, spec1, spec2,itemQuant, sql;
            double retail, dropShip, subCost, grossProfit, netProfit, payout;
            double bv,cv,qv,cost, employee, bbr, orig_bbr, orig_qv;                  
            bool itemDiscon;
            string a1="", a2="", added_date, sql1, description;
            string return_val = new string((char)10,1);//converts ascii characters.
            string hardReturn = new string((char)13,1); //converts ascii characters.
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            

            private OleDbDataReader rsquery(string sqlCmd)
            {
                  try
                  {
                        string connectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(dbPath);
                        conn.ConnectionString = connectString;                                          
                        cmd.CommandText = sqlCmd;
                        cmd.Connection = conn;
                        conn.Open();
                        OleDbDataReader reader = cmd.ExecuteReader();            
                        return reader;
                  }
                  catch(Exception err)
                  {
                        lbl_msg.Text ="Error in rsquery Function<br>" +  err.Message + "<br>" + err.StackTrace;
                        return null;
                  }
            }
            
            private DataSet dsetrs(string sqlCmd, string tableName)
            {
                  try
                  {
                        string connectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(dbPath);
                        conn.ConnectionString = connectString;                                          
                        OleDbDataAdapter oDA = new OleDbDataAdapter(sqlCmd, conn);
                        DataSet dSet = new DataSet();            
                        oDA.Fill(dSet,tableName);
                        conn.Close();
                        return dSet;
                  }
                  catch(Exception err)
                  {
                        lbl_msg.Text ="Error in dsetrs Function<br>" +  err.Message + "<br>" + err.StackTrace;
                        return null;
                  }
            }

            private void query(string sqlCmd)
            {
                  try
                  {
                        string connectString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(dbPath);
                        conn.ConnectionString = connectString;
                        conn.Open();                                    
                        cmd.CommandText = sqlCmd;
                        cmd.Connection = conn;
                        cmd.ExecuteNonQuery();                  
                        conn.Close();
                  }
                  catch(Exception err)
                  {
                        lbl_msg.Text ="Error in query Function<br>" +  err.Message + "<br>" + err.StackTrace;
                  }
            }
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            protected void Page_Load(object sender, System.EventArgs e)
            {
                  if(!IsPostBack)
                  {
                        int newCnt = 20;
                        ArrayList values = new ArrayList();
                        for (int i=0; i < newCnt; i++)
                        {
                              values.Add("");
                        }                  

                        MyList1.DataSource = values;
                        MyList1.DataBind();

                        populate_form();
                  }
            }
            
            protected void btn_upload_Click(object sender, System.EventArgs e)
            {
                  save_uploads();
            }

            private void additional_recs()
            {
                  int newCnt = 20;
                  ArrayList values = new ArrayList();
                  for (int i=0; i < newCnt; i++)
                  {
                        values.Add("");
                  }                  

                  MyList1.DataSource = values;
                  MyList1.DataBind();
            }
//##################################################################################
//################# Populate Form ###################################################            
            private void populate_form()
            {
                  // Populate cat1, vendor, manufactures, headings here.                  
                  OleDbDataReader rs;

                  sql = "Select * from cat3 order by cat3";
                  rs = rsquery(sql);
                  cat3.DataSource = rs;
                  cat3.DataTextField = "cat3";
                  cat3.DataValueField = "cat3";
                  cat3.DataBind();
                  cat3.Items.Insert (0,"Select Category");
                  rs.Close();
                  conn.Close();
                        
                  sql = "Select * from Vendors order by vendor";
                  rs = rsquery(sql);
                  vend.DataSource = rs;
                  vend.DataTextField = "Vendor";
                  vend.DataValueField = "id";
                  vend.DataBind();
                  vend.Items.Insert (0,"Select");
                  rs.Close();
                  conn.Close();
                        
                  sql = "Select * from Manufactures order by manufacture";
                  rs = rsquery(sql);
                  man.DataSource = rs;
                  man.DataTextField = "Manufacture";
                  man.DataValueField = "id";
                  man.DataBind();
                  man.Items.Insert (0,"Select");
                  rs.Close();
                  conn.Close();

                  sql = "Select * from headings order by heading";
                  rs = rsquery(sql);
                  h1.DataSource = rs;
                  h1.DataTextField = "heading";
                  h1.DataValueField = "heading";
                  h1.DataBind();
                  h1.Items.Insert (0,"Select");
                  rs.Close();
                  conn.Close();
                        
                  sql = "Select * from headings order by heading";
                  rs = rsquery(sql);
                  h2.DataSource = rs;
                  h2.DataTextField = "heading";
                  h2.DataValueField = "heading";
                  h2.DataBind();
                  h2.Items.Insert (0,"Select");
                  rs.Close();
                  conn.Close();                  
            }
//###################################################################################
//################# Upload Images ###################################################
            private void save_uploads()
            {                  
                  //string strMessage = "";
                  string saveLocation;
                  
                  HttpPostedFile lowRes;
                  HttpPostedFile highRes;
                  lowRes = Request.Files["file_low"];
                  highRes = Request.Files["file_high"];

                  //Low res image
                  if (lowRes.FileName != "")
                  {
                        lowResName = lowRes.FileName;                  
                        lowResName = lowResName.Substring(lowResName.LastIndexOf("\\")+1);                        
                        low_res.Text = nDate.Second + nDate.Millisecond  + lowResName;
                        string errMsg = "";
                        
                        try
                        {//save image, description and section.
                              if(lowRes.ContentType != "image/gif" && lowRes.ContentType != "image/pjpeg")
                              {            
                                    errMsg += "Low resolution image is not of type JPEG or GIF.<br>";
                              }

                              if(lowRes.ContentLength > 55000)
                              {
                                    errMsg += "Low resolution image is too big. Please adjust the size to be less then 50kb.<br>";
                              }
                   
                              if (errMsg.Length > 0)
                              {
                                    lblLowRes.Text = errMsg;
                              }

                              else
                              {
                                    saveLocation = Server.MapPath("../images/" + low_res.Text);
                                    lowRes.SaveAs(saveLocation);      
                                    lblLowRes.Text = "Low Res images uploaded successfull.";
                                    //Display thumbnail of low res.
                                    img.ImageUrl = "../images/" + low_res.Text;
                                    img.Width = 100;
                                    img.Height = 100;                                                            
                              }
                        }
                        catch(Exception err)
                        {                              
                              lbl_msg.Text ="Error in Images<br>" +  err.Message + "<br>" + err.StackTrace;            
                        }                  
                  }    

                  //High REs Images
                  if (highRes.FileName != "")
                  {                        
                        highResName = highRes.FileName;      
                        
                        highResName = highResName.Substring(highResName.LastIndexOf("\\")+1);
                        high_res.Text = (nDate.Second + nDate.Millisecond + highResName.Trim());
                        
                        try
                        {//save image, description and section.
                              if(highRes.ContentLength < 120000)
                              {
                                    lblHighRes.Text = "High Res image file size is to small to qualify. Please adjust.";
                              }
                              else
                              {
                                    saveLocation = Server.MapPath("../highres/" + high_res.Text);
                                    highRes.SaveAs(saveLocation);      
                                    lblHighRes.Text = "High Res image uploaded successfully.";            
                              }
                        }
                        catch(Exception err)
                        {                              
                              lbl_msg.Text ="Error in Images<br>" +  err.Message + "<br>" + err.StackTrace;            
                        }                  
                  }


            }


//##################################################################################
//################# ADD ITEMS ###################################################
            private void add_new_items()
            {
                  foreach(RepeaterItem dataItem in MyList1.Items) //Add new items
                  {
                        //Add first item

                        retailText = (TextBox)dataItem.FindControl("Textbox5");
                        dropShipText = (TextBox)dataItem.FindControl("Textbox6");
                        costText = (TextBox)dataItem.FindControl("Textbox7");                        
                        spec1Text = (TextBox)dataItem.FindControl("Textbox1");
                        spec2Text = (TextBox)dataItem.FindControl("Textbox2");
                        manText = (TextBox)dataItem.FindControl("Textbox4");
                        vendText = (TextBox)dataItem.FindControl("Textbox3");
                        bbrText = (TextBox)dataItem.FindControl("Textbox8");
                        qvText = (TextBox)dataItem.FindControl("Textbox10");
                        quantText = (TextBox)dataItem.FindControl("Textbox9");

                        string part_number = "";
                        
                        if(retailText.Text != "")//Don't bother with items that are empty
                        {
                              //Generate part number
                              try
                              {
                                    sql = "update auto_ids set inc_val=(inc_val + 1) where purpose='catalog'";
                                    query(sql);
                              }
                              catch(Exception err1)
                              {
                                    lbl_msg.Text= "Error in New Part Number<br>" + err1.Message;
                              }
                        
                              //Retrieve Part number.
                              try
                              {
                                    sql = "Select inc_val from auto_ids where purpose='catalog'";
                                    OleDbDataReader rs = rsquery(sql);
                                    rs.Read();
                                    part_number = rs.GetValue(0).ToString();      
                                    rs.Close();
                                    conn.Close();
                              }
                              catch(Exception err2)
                              {
                                    lbl_msg.Text= "Error in New Part Number<br>" + err2.Message;
                              }
                              
                              if(dropShipText.Text == "")
                              {
                                    dropShipText.Text = "0";
                              }
                        
                              if(costText.Text == "")
                              {
                                    costText.Text = "0";
                              }

                              if(quantText.Text == "")
                              {
                                    quantText.Text = "0";
                              }
                        
                              description = desc.Text.Replace(return_val,"<br>");
                              description = description.Replace("'","`");
                              description = description.Replace(hardReturn,"");

                              spec1 = spec1Text.Text.ToString().Trim();
                              spec2 = spec2Text.Text.ToString().Trim();
                              manNumber = manText.Text.ToString().Trim();
                              vendNumber = vendText.Text.ToString().Trim();
                              itemQuant = quantText.Text.ToString().Trim();
                              itemDiscon = disconText.Checked;
                              partNumber = partNumText.Text;                        
                              retail = Convert.ToDouble(retailText.Text);
                              dropShip = Convert.ToDouble(dropShipText.Text);
                              subCost = Convert.ToDouble(costText.Text);

                              //--- Validate data -----------------------------
                              if (dropShip.Equals(""))
                              {
                                    Response.Write("Zero Value");
                                    Response.End();
                              }

                              string valMan = msg.validate_text(manNumber,1,"You forgot a manufacture part number");
                              string valVend = msg.validate_text(vendNumber,1,"You forgot a vendor part number");      

                              if(valMan.Length > 0)
                              {
                                    Response.Write(valMan);
                                    Response.End();
                              }

                              if(valVend.Length > 0)
                              {
                                    Response.Write(valVend);
                                    Response.End();
                              }

                              if (bbrText.Text == "")
                              {
                                    bbrText.Text = "0";
                              }

                              if (qvText.Text == "")
                              {
                                    qvText.Text = "0";
                              }

                              orig_bbr = Convert.ToDouble(bbrText.Text);
                              orig_qv = Convert.ToDouble(qvText.Text);

                              //--- run calculations -------------------------
                              cost = (retail * .15) + (subCost + dropShip);

                              employee = cost;
                              if (employee > retail)
                              {
                                    employee = retail;
                              }

                              grossProfit = (retail - cost);
                              bbr = (grossProfit * .20);                  
                              netProfit = (grossProfit - bbr);
                              payout = (netProfit * .5);

                              bv = (payout * .6);
                              if (bv <.01)
                              {
                                    bv = 0;
                              }

                              cv = (payout * .4) * 5;
                              if(cv < .01)
                              {
                                    cv = 0;
                              }

                              qv = (bv * 2);
                              if (qv < .01)
                              {
                                    qv = 0;
                              }
                              
                              qv = (bv * 2);                              
                              if (orig_qv > qv && orig_qv <= retail) //Change QV only if its less then 100% of retail and greater then calculated QV.
                              {
                                    qv = orig_qv;
                              }
                              else
                              {                              
                                    if (qv < .01)
                                    {
                                          qv = 0;
                                    }
                              }

                              bbr = Math.Round(bbr);
                              if (orig_bbr > bbr && orig_bbr <= retail) //Change bbr only if its less then 100% of retail and greater then calculated BBR.
                              {
                                    bbr = Math.Round(orig_bbr);
                              }
                              else
                              {                              
                                    if (bbr < 1)
                                    {
                                          bbr = 0;
                                    }                              
                              }

                              //Response.Write("Retail: " + retail + "<br>Base Cost: " + subCost + "<br>dropShip: " + dropShip + "<br>Cost: " + cost + "<br>Employee: " + employee + "<br>Gross Profit: " + grossProfit + "<br>BBR: " + bbr + "<br>net Profit: " + netProfit + "<br>payout: " + payout + "<br>BV: " + bv + "<br>CV: " + cv + "<br>QV: " + qv + "<br>");

                              //Response.End();


                              try
                              {                  
                                                
                                    added_date = nDate.Month + "/" + nDate.Day + "/" + nDate.Year;

                                    if (low_res.Text == "")
                                    {
                                          lowResName = "no_img.jpg";
                                    }
                                                
                                    if (h1.SelectedValue != "Select")
                                    {
                                          a1 = h1.SelectedValue;
                                    }
                                    if (h2.SelectedValue != "Select")
                                    {
                                          a2 = h2.SelectedValue;
                                    }                        

                                    //build sql from form values.                        
                                    sql1 = "Insert into Inventory (cat1,sect,cat2,Vendor,Manufacture,Part_Number,Vendor_Part_Number,Manufacture_Part_Number,Name,Item_Name,Description,Quantity,Retail,Employee,BV,CV,QV,drop_ship_cost,Sub_Cost,Cost,Profit,BBR,productImg,h1,h2,spec1,spec2,user_spec1,user_spec2,user_spec3,user_spec4,Date_Added,shipping_class,ship_time,high_res_img,print_cat) values(" + cat1.SelectedValue + "," + catalog_pick.SelectedValue + "," + cat2.SelectedValue + "," + vend.SelectedValue + "," + man.SelectedValue + ",'" + part_number + "','" + vendNumber + "','" + manNumber + "','" + cat3.SelectedValue + "','" + item_name.Text + "','" + description + "'," + itemQuant + "," + retail + "," + employee + "," + bv + "," + cv + "," + qv + "," + dropShip + "," + subCost + "," + cost + "," + grossProfit + "," + bbr + ",'images/" + low_res.Text + "','" + a1 + "','" + a2 + "','" + spec1 + "','" + spec2 + "','" + u1.Text + "','" + u2.Text + "','" + u3.Text + "','" + u4.Text + "','" + added_date + "'," + radShipClass.SelectedValue + "," + shipping.SelectedValue + ",'" + high_res.Text + "'," + chkPrint.Checked + ")";            
            
                                    //insertCmd = sql1;
                                    conn.Close();
                                    query(sql1);
                                    //Remove text box values
                                    retailText.Text = "";                                    
                                    dropShipText.Text = "";
                                    costText.Text = "";                  
                                    spec1Text.Text = "";
                                    spec2Text.Text = "";
                                    manText.Text = "";
                                    vendText.Text = "";
                                    bbrText.Text = "";
                                    qvText.Text = "";
                                    quantText.Text = "";
                                    
                                    txt5.Text = "";
                                    txt6.Text = "";
                                    txt7.Text = "";            
                                    txt4.Text = "";
                                    txt3.Text = "";
                                    txt8.Text = "";
                                    txt10.Text = "";
                                    txt9.Text = "";
                                    lbl_msg.Text= "Item(s) added successfully!";
                              }
                              catch(Exception err)
                              {
                                    lbl_msg.Text= "Error in Add Items<br>" + err.Message;
                              }
                        }
                  }                  
            }

            protected void catalog_pick_SelectedIndexChanged(object sender, System.EventArgs e)
            {
                  cat2.DataSource = "";
                  cat2.DataTextField = "";
                  cat2.DataValueField = "";

            //hunting
                  if (catalog_pick.SelectedValue == "1")
                  {
                        sql = "Select * from cat1 where category=1 order by cat1";
                  } //fishing
                  else if(catalog_pick.SelectedValue == "2")
                  {
                        sql = "Select * from cat1 where category=2 order by cat1";
                  } //both
                  else
                  {
                        sql = "Select * from cat1 where category=3 order by cat1";
                  }

                  try
                  {                        
                        OleDbDataReader rs = rsquery(sql);
                        cat1.DataSource = rs;
                        cat1.DataTextField = "cat1";
                        cat1.DataValueField = "id";
                        cat1.DataBind();
                        cat1.Items.Insert (0,"Select Category");
                        rs.Close();
                        conn.Close();
                  }
                  catch(Exception err)
                  {
                        lbl_msg.Text ="Error in Catalog selection<br>" +  err.Message + "<br>" + err.StackTrace;
                  }
            }

            protected void cat1_SelectedIndexChanged(object sender, System.EventArgs e)
            {
                  try
                  {                        
                        sql = "Select * from cat2 where catid=" + cat1.SelectedValue + " order by cat2";
                        OleDbDataReader rs = rsquery(sql);
                        cat2.DataSource = rs;
                        cat2.DataTextField = "cat2";
                        cat2.DataValueField = "id";
                        cat2.DataBind();
                        cat2.Items.Insert (0,"Select Category 2");
                        rs.Close();
                        conn.Close();
                  }
                  catch(Exception err)
                  {
                        lbl_msg.Text ="Error in Cat1 selection<br>" +  err.Message + "<br>" + err.StackTrace;
                  }
            }            

            private void btnCancel_Click(object sender, System.EventArgs e)
            {
                  Response.Redirect("products_locate.aspx");
                  //Response.Write("It is here");
            }

            private void btnCancel3_Click(object sender, System.EventArgs e)
            {
                  Response.Redirect("products_locate.aspx");
            }

            private void btnCancel2_Click(object sender, System.EventArgs e)
            {
                  Response.Redirect("products_locate.aspx");
            }

            protected void btnUpdate2_Click(object sender, System.EventArgs e)
            {
                  add_new_items();
            }

            protected void update_Click(object sender, System.EventArgs e)
            {
                  add_new_items();
            }

            protected void btnUpdate1_Click(object sender, System.EventArgs e)
            {
                  add_new_items();
            }

            protected void btnCopy_Click(object sender, System.EventArgs e)
            {
            Response.Redirect("http://www.google.com");
                  foreach(RepeaterItem dataItem in MyList1.Items) //Add new items
                  {
                        retailText = (TextBox)dataItem.FindControl("Textbox5");
                        dropShipText = (TextBox)dataItem.FindControl("Textbox6");
                        costText = (TextBox)dataItem.FindControl("Textbox7");                        
                        spec1Text = (TextBox)dataItem.FindControl("Textbox1");
                        spec2Text = (TextBox)dataItem.FindControl("Textbox2");
                        manText = (TextBox)dataItem.FindControl("Textbox4");
                        vendText = (TextBox)dataItem.FindControl("Textbox3");
                        bbrText = (TextBox)dataItem.FindControl("Textbox8");
                        qvText = (TextBox)dataItem.FindControl("Textbox10");
                        quantText = (TextBox)dataItem.FindControl("Textbox9");

                        //retailText.Text = txt5.Text;
                        dropShipText.Text = txt6.Text;
                        costText.Text = txt7.Text;                        
                        manText.Text = txt4.Text;
                        vendText.Text = txt3.Text;
                        bbrText.Text = txt8.Text;
                        qvText.Text = txt10.Text;
                        quantText.Text = txt9.Text;
                  }

            }

    protected void update_Click1(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("http://www.rodmjay.com");
    }
}



0
rodmjay
Asked:
rodmjay
1 Solution
 
Raju SrivatsavayeSoftware EngineerCommented:
Does it throw an error or it just doesnt fire at all..
Try using server.transfer and see if that works
0
 
aki4uCommented:
Did you try to double click on the button in Designer view (it will take you to the sub btnCopy_Click?
Sometimes this can happen.
0
 
aki4uCommented:
or try deleting the button and adding a new one
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rodmjayAuthor Commented:
I have tried all of these things and they work as they are supposed to.  I even created a new page in the same directory to see if it worked like it was supposed to and it did
0
 
aki4uCommented:
Do you have CausesValidation="False" set fot this button?
Change it to "True" or remove whole attribute.
0
 
GavinMannionCommented:
I had this happen once for no apparent reason.

Rename

protected void btnCopy_Click(object sender, System.EventArgs e)

to

protected void btnCopy_Click_TESTING(object sender, System.EventArgs e)

and then double click on your button It should then recreate an event handler. Copy all your code into that one.
0
 
aki4uCommented:
Hi,

Try this link:

File upload with ASP.NET
http://www.codeproject.com/aspnet/fileupload.asp
0
 
aki4uCommented:
Sorry,wrong post ;)
0
 
rodmjayAuthor Commented:
This is where it gets weirder...  I rewrite the page in vb.net and the button still doesnt register the event.   herer is the code

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.OleDb
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Partial Class catalog_cat_admin_add_items0
    Inherits System.Web.UI.Page

    Dim dbPath As String = "../../data/mlm.mdb"
    Dim conn As New System.Data.OleDb.OleDbConnection
    Dim cmd As New System.Data.OleDb.OleDbCommand

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then
            'build the datalist to 20 levels
            Dim i As Integer = 20
            Dim al As New ArrayList
            For i = 0 To i
                al.Add("")
            Next

            MyList1.DataSource = al
            MyList1.DataBind()

            PopulateForm()
        End If

    End Sub

    Private Sub PopulateForm()

        Dim rs As OleDbDataReader

        Dim sql As String = "Select * from cat3 order by cat3"
        rs = rsquery(sql)
        cat3.DataSource = rs
        cat3.DataTextField = "cat3"
        cat3.DataValueField = "cat3"
        cat3.DataBind()
        cat3.Items.Insert(0, "Select Category")
        rs.Close()
        conn.Close()

        sql = "Select * from Vendors order by vendor"
        rs = rsquery(sql)
        vend.DataSource = rs
        vend.DataTextField = "Vendor"
        vend.DataValueField = "id"
        vend.DataBind()
        vend.Items.Insert(0, "Select")
        rs.Close()
        conn.Close()

        sql = "Select * from Manufactures order by manufacture"
        rs = rsquery(sql)
        man.DataSource = rs
        man.DataTextField = "Manufacture"
        man.DataValueField = "id"
        man.DataBind()
        man.Items.Insert(0, "Select")
        rs.Close()
        conn.Close()

        sql = "Select * from headings order by heading"
        rs = rsquery(sql)
        h1.DataSource = rs
        h1.DataTextField = "heading"
        h1.DataValueField = "heading"
        h1.DataBind()
        h1.Items.Insert(0, "Select")
        rs.Close()
        conn.Close()

        sql = "Select * from headings order by heading"
        rs = rsquery(sql)
        h2.DataSource = rs
        h2.DataTextField = "heading"
        h2.DataValueField = "heading"
        h2.DataBind()
        h2.Items.Insert(0, "Select")
        rs.Close()
        conn.Close()

    End Sub

    Private Function rsquery(ByVal sqlCmd As String) As OleDbDataReader

        Try
            Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(dbPath)
            conn.ConnectionString = connString
            cmd.CommandText = sqlCmd
            cmd.Connection = conn
            conn.Open()
            Dim reader As OleDbDataReader = cmd.ExecuteReader
            Return reader
        Catch ex As Exception
            lbl_msg.Text = "Error in rsFunction"
            Return Nothing
        End Try

    End Function

    Protected Sub catalog_pick_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles catalog_pick.SelectedIndexChanged

        cat2.DataSource = ""
        cat2.DataTextField = ""
        cat2.DataValueField = ""

        Dim sql As String
        'hunting
        If catalog_pick.SelectedValue = 1 Then
            sql = "Select * from cat1 where category=1 order by cat1;"
        ElseIf catalog_pick.SelectedValue = 2 Then
            sql = "Select * from cat1 where category=2 order by cat1;"
        Else
            sql = "Select * from cat1 where category=3 order by cat1;"
        End If

        Try
            Dim rs As OleDbDataReader = rsquery(sql)
            cat1.DataSource = rs
            cat1.DataTextField = "cat1"
            cat1.DataValueField = "id"
            cat1.DataBind()
            'cat1.Items.Insert(0, "Select Category")
            rs.Close()
            conn.Close()
        Catch ex As Exception
            lbl_msg.Text = "Error in Catalog selection<br>" + ex.Message + "<br>" + ex.StackTrace
        End Try

    End Sub

    Protected Sub cat1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cat1.SelectedIndexChanged
        Try
            Dim sql As String = "Select * from cat2 where catid=" + cat1.SelectedValue + " order by cat2"
            Dim rs As OleDbDataReader = rsquery(sql)
            cat2.DataSource = rs
            cat2.DataTextField = "cat2"
            cat2.DataValueField = "id"
            cat2.DataBind()
            cat2.Items.Insert(0, "Select Category 2")
            rs.Close()
            conn.Close()
        Catch ex As Exception
            lbl_msg.Text = "Error in Cat1 selection<br>" + ex.Message + "<br>" + ex.StackTrace
        End Try
    End Sub

    Protected Sub btnCopy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCopy.Click
        Server.Transfer("http://google.com")
        Dim item As RepeaterItem
        For Each item In MyList1.Items

            Dim retailText As TextBox = CType(item.FindControl("Textbox5"), TextBox)
            Dim dropShipText As TextBox = CType(item.FindControl("Textbox6"), TextBox)
            Dim costText As TextBox = CType(item.FindControl("Textbox7"), TextBox)
            Dim spec1Text As TextBox = CType(item.FindControl("Textbox1"), TextBox)
            Dim spec2Text As TextBox = CType(item.FindControl("Textbox2"), TextBox)
            Dim manText As TextBox = CType(item.FindControl("Textbox4"), TextBox)
            Dim vendText As TextBox = CType(item.FindControl("Textbox3"), TextBox)
            Dim bbrText As TextBox = CType(item.FindControl("Textbox8"), TextBox)
            Dim qvText As TextBox = CType(item.FindControl("Textbox10"), TextBox)
            Dim quantText As TextBox = CType(item.FindControl("Textbox9"), TextBox)

            retailText.Text = txt5.Text
            dropShipText.Text = txt6.Text
            costText.Text = txt7.Text
            manText.Text = txt4.Text
            vendText.Text = txt3.Text
            bbrText.Text = txt8.Text
            qvText.Text = txt10.Text
            quantText.Text = txt9.Text
        Next

    End Sub

    Protected Sub btnUpdate2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate2.Click
        Response.Redirect("http://www.google.com")
    End Sub
End Class
0
 
rodmjayAuthor Commented:
none of the redirects or transfers work.  However the postbacks for the radiobuttonlist and the dropdownlists work great
0
 
aki4uCommented:
Do you have CausesValidation="False" set fot this button?
Change it to "True" or remove whole attribute.

How do you add these events? Double clicking on control in Designer View?
0
 
rodmjayAuthor Commented:
causes validation is not on, and even if it was that would still do the post back and run the redirect.
0
 
aki4uCommented:
does the postback work if you create a new page?
0
 
rodmjayAuthor Commented:
yes and no.  I created an entirely new page called test.aspx that just has a button that does a redirect.  This file is in the same directory and it works.  When I tried to convert the page to vb.net instead of c# i copied the html within the "form" tags.  (I just wanted a skeleton to do the processing).  So the test page and the vb.net page look exactly the same outside of the form tag.  The vb.net page though doesnt work.  Here are the two pages and you can tell me what you think.

http://huntn.biz/catalog/cat_admin/add_items0.aspx
http://huntn.biz/catalog/cat_admin/test.aspx
0
 
rodmjayAuthor Commented:
the main buttons i need to work are copy and add items
0
 
aki4uCommented:
You can't just copy the html content!
What you need to do is to open your page in designer view so you see all of your controls. Now, for each control that you want to respond to click or changeindex event or whatever event, you must double click it.
E.g.
You have "Go Back" button on which you must double click what will take you to codebehind file, exactly to event sub of the button. Now, go back to design view and do that for each control that requires this.

If you're still having problems, you can send me your files to examine them, if you'd like to.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now