Click here to Skip to main content
15,899,313 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: passing session details from user control Pin
dotnetcsharpdev3-Sep-09 1:37
dotnetcsharpdev3-Sep-09 1:37 
GeneralRe: passing session details from user control Pin
Not Active3-Sep-09 2:01
mentorNot Active3-Sep-09 2:01 
GeneralRe: passing session details from user control Pin
dotnetcsharpdev3-Sep-09 5:45
dotnetcsharpdev3-Sep-09 5:45 
AnswerRe: passing session details from user control Pin
Arun Jacob3-Sep-09 2:21
Arun Jacob3-Sep-09 2:21 
GeneralRe: passing session details from user control Pin
Not Active3-Sep-09 2:23
mentorNot Active3-Sep-09 2:23 
QuestionImage Display using Asp:Image Pin
Amit Patel19853-Sep-09 0:42
Amit Patel19853-Sep-09 0:42 
AnswerRe: Image Display using Asp:Image Pin
Christian Graus3-Sep-09 2:08
protectorChristian Graus3-Sep-09 2:08 
QuestionDetailsView Pin
allanrai3-Sep-09 0:11
allanrai3-Sep-09 0:11 
how can i use   edit update function in detailsview as i use in grid view.plz help me out ......thanks in Advance...........

using System;
using System.Data;
using System.Configuration;
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;
using System.IO;
public partial class Update_Finance_Details_After_Bill : System.Web.UI.Page
{
      protected void Page_Load(object sender, EventArgs e)
      {
            if (!IsPostBack)
            {
                  BindData();
            }
      }
      private void BindData()
      {
            SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter("SELECT SL_NO,GRC_No, Name_of_person, Name_Or_Number_Of_Rooms_Occupied , Date,   Time, Check_In_No,Sale_Voucher_No,Party_Debit_Voucher_No FROM LHPL", con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
      }


      protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
      {
            GridView1.EditIndex = e.NewEditIndex;
            BindData();
      }
      protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
      {
            GridView1.EditIndex = -1;
            BindData();
      }
      protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
      {

            if (((LinkButton)GridView1.Rows[0].Cells[0].Controls[0]).Text == "Insert")
            {
                  SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
                  SqlCommand cmd = new SqlCommand();
                  cmd.CommandText = "INSERT INTO LHPL(Party_Debit_Voucher_No) VALUES(@Party_Debit_Voucher_No)";
                  cmd.Parameters.Add("@Party_Debit_Voucher_No", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[0].Cells[2].Controls[0]).Text;

                  cmd.Connection = con;
                  con.Open();
                  cmd.ExecuteNonQuery();
                  con.Close();
            }
            else
            {
                  SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
                  SqlCommand cmd = new SqlCommand();
                  cmd.CommandText = "UPDATE LHPL SET Party_Debit_Voucher_No=@Party_Debit_Voucher_No WHERE SL_NO=@SL_NO";
                  cmd.Parameters.Add("@Party_Debit_Voucher_No", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
                  cmd.Parameters.Add("@SL_NO", SqlDbType.Int).Value = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);
                  cmd.Connection = con;
                  con.Open();
                  cmd.ExecuteNonQuery();
                  con.Close();

            }


            GridView1.EditIndex = -1;
            BindData();
      }

      protected void btnAdd_Click(object sender, EventArgs e)
      {
            SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter("SELECT SL_NO,Sale_Voucher_No,GRC_No ,Party_Debit_Voucher_NoFROM LHPL", con);
            DataTable dt = new DataTable();
            da.Fill(dt);

            // Here we'll add a blank row to the returned DataTable
            DataRow dr = dt.NewRow();
            dt.Rows.InsertAt(dr, 0);
            //Creating the first row of GridView to be Editable
            GridView1.EditIndex = 0;
            GridView1.DataSource = dt;
            GridView1.DataBind();
            //Changing the Text for Inserting a New Record
            ((LinkButton)GridView1.Rows[0].Cells[0].Controls[0]).Text = "Insert";

      }
      protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
      {
            SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "DELETE FROM LHPL WHERE SL_NO=@SL_NO";
            cmd.Parameters.Add("@SL_NO", SqlDbType.Int).Value = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);

            cmd.Connection = con;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            BindData();

      }

      protected void TextBox1_TextChanged(object sender, EventArgs e)
      {

      }
      protected void TextBox2_TextChanged(object sender, EventArgs e)
      {

      }


      protected void Button3_Click(object sender, EventArgs e)
      {

      }
      protected void Button4_Click(object sender, EventArgs e)
      {


            SqlConnection con = new SqlConnection("Data Source=software;Initial Catalog=LHPL_INFO;Integrated Security=True");
            SqlDataAdapter da = new SqlDataAdapter("SELECT SL_NO,GRC_No, Name_of_person, Name_Or_Number_Of_Rooms_Occupied , Date,   Time, Check_In_No ,Sale_Voucher_No ,Party_Debit_Voucher_No FROM LHPL where GRC_No ='" + TextBox1.Text + "'", con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
      }

      protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
      {

      }

      protected void Button2_Click1(object sender, EventArgs e)
      {

      }

}
QuestionSecurity exception after hosting Pin
reogeo20082-Sep-09 23:22
reogeo20082-Sep-09 23:22 
AnswerRe: Security exception after hosting Pin
SeMartens2-Sep-09 23:45
SeMartens2-Sep-09 23:45 
Questionexchange information between server and client Pin
marwa_noor2-Sep-09 23:15
marwa_noor2-Sep-09 23:15 
AnswerRe: exchange information between server and client Pin
Christian Graus3-Sep-09 2:09
protectorChristian Graus3-Sep-09 2:09 
QuestionMulti-Language Support for Application Pin
Aman Bhullar2-Sep-09 21:46
Aman Bhullar2-Sep-09 21:46 
AnswerRe: Multi-Language Support for Application Pin
Abhishek Sur2-Sep-09 21:52
professionalAbhishek Sur2-Sep-09 21:52 
GeneralRe: Multi-Language Support for Application Pin
Aman Bhullar2-Sep-09 22:03
Aman Bhullar2-Sep-09 22:03 
GeneralRe: Multi-Language Support for Application Pin
Abhijit Jana2-Sep-09 23:51
professionalAbhijit Jana2-Sep-09 23:51 
GeneralRe: Multi-Language Support for Application Pin
Aman Bhullar3-Sep-09 5:33
Aman Bhullar3-Sep-09 5:33 
GeneralRe: Multi-Language Support for Application Pin
Abhishek Sur3-Sep-09 9:21
professionalAbhishek Sur3-Sep-09 9:21 
GeneralRe: Multi-Language Support for Application Pin
Aman Bhullar4-Sep-09 5:45
Aman Bhullar4-Sep-09 5:45 
Question& instead of &amp [modified] Pin
Piya B2-Sep-09 20:49
Piya B2-Sep-09 20:49 
AnswerRe: & instead of &amp Pin
SeMartens2-Sep-09 21:59
SeMartens2-Sep-09 21:59 
GeneralRe: & instead of &amp Pin
Piya B2-Sep-09 22:21
Piya B2-Sep-09 22:21 
GeneralRe: & instead of &amp Pin
SeMartens2-Sep-09 22:24
SeMartens2-Sep-09 22:24 
GeneralRe: & instead of &amp Pin
Piya B2-Sep-09 22:27
Piya B2-Sep-09 22:27 
GeneralRe: & instead of &amp Pin
SeMartens2-Sep-09 22:31
SeMartens2-Sep-09 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.