ASP.NET C# Web Development project

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nithy
    New Member
    • Oct 2008
    • 1

    ASP.NET C# Web Development project

    I am doing Web Development project using ASP.NET C# as front-end & MS SQL Server 2005 as back-end. I am not familiar to ASP.NET C#, i need some help.
    I am doing project for maintaining the leave details of employees. During run time when i will select "employee id" from dropdownlist, "type of leave" from radiobutton, entering the "number of leaves" in textbox & finally i will click save button. When i click the save button the values in textbox should be added to corresponding field values in database, by refering employee id from dropdownlist & types of leave from radiobuttons. If any will send a code, it will very useful for me. I will also attach my coding of the project below:
    Code:
    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;
    using System.Data.SqlClient;
    
    public partial class rb : System.Web.UI.Page
    {
        Int32 days, rows;
        String ltype;
    
    
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.RadioButton1.Checked == true)
                ViewState["strLeave"] = RadioButton1.Text;
            else if (this.RadioButton2.Checked == true)
                ViewState["strLeave"] = RadioButton2.Text;
            this.Label1.Text = "u r selected " + ViewState["strLeave"];
    
        }
        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (RadioButton1.Checked)
            {
                RadioButton1.Visible = true;
                ltype = "cl";
            }
            else
                RadioButton2.Visible = true;
        }
        protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (RadioButton2.Checked)
            {
                RadioButton2.Visible = true;
                ltype = "el";
            }
            else
                RadioButton1.Visible = true;
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ddlIndex = this.DropDownList1.SelectedIndex;
    
            this.lblDdlCheck.Text = this.DropDownList1.SelectedItem.Text;
        }
    
        protected void Button2_Click(object sender, EventArgs e)
        {
            SqlDataReader reader = null;
            SqlConnection scon = null;
            try
            {
                scon = new SqlConnection(@"Data Source = localhost; Initial Catalog = vel; Integrated Security = True");
                scon.Open();
                Response.Write("should have opened a connection by now");
                Response.Write(rows);
                days = Convert.ToInt32(TextBox1.Text);
                string strQuery = "select cl,el from leave_details where empid = 2";
    
    
                Convert.ToInt32(TextBox1.Text);
                SqlCommand cmd = new SqlCommand(strQuery, scon);
                rows = cmd.ExecuteNonQuery();
                Response.Write(rows);
                }
            catch (Exception e1)
            {
                Response.Write("SQL connection exception" + e1.ToString());
            }
            try
            {
                catch (Exception ex)
            {
                Response.Write("SQL Exception occured" + ex.ToString());
            }
              scon.Close();
       }
            
            protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            days = Convert.ToInt32(TextBox1.Text);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        
        protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
    
        }
        protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
    
        }
    
    
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
    
        }
        protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
        {
    
        }
        void GridView1_RowUpdated(Object sender, GridViewUpdateEventArgs e)
        {
            //Retrieve the row being edited.
            int index = GridView1.EditIndex;
            GridViewRow row = GridView1.Rows[index];
    
            // Retrieve the value of the first cell
            lblDdlCheck.Text = "Updated record" + row.Cells[1].Text;
        }
    
        protected void GridView1_SelectedIndexChanged2(object sender, EventArgs e)
        {
    
        }
    }
    Last edited by DrBunchman; Oct 8 '08, 07:01 AM. Reason: Added [Code] Tags - Please use the '#' button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi nithy,

    Welcome to Bytes.com! I hope you find the site useful.

    You've posted your question in the ASP Forum which is for Classic ASP only - I've moved it for you but in future please post all ASP.NET questions in the .NET Forum.

    Please don't forget to wrap your code in CODE tags - it makes your posts much easier to read - and please read the Posting Guidelines if you have not done so already.

    Furthermore, what is the actual problem you are having? Are you receiving any errors? The experts here won't write your code for you but we can help you with specific problems that you are having.

    Dr B

    Comment

    Working...