gridview update

Discussion in 'Software' started by Bobby, Dec 11, 2007.

  1. Bobby

    Bobby

    Joined:
    Dec 10, 2007
    Messages:
    1
    Hi I have problem with Upgate grid view could you please help me with this.when i write the query in toad it works good but when i use it in the code it returns run time error? Can you please help me

    Thanks in Advance

    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 Oracle.DataAccess.Client;

    public partial class EDIT_UPDATE : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    BindData();
    }
    public void BindData()
    {
    OracleConnection cn = new OracleConnection();
    OracleCommand cm = new OracleCommand();
    DataSet ds = new DataSet();
    OracleDataAdapter da = new OracleDataAdapter();
    try
    {
    cn.ConnectionString = "Data Source=MISC;User ID=SO;Password=SO";
    cn.Open();

    cm.Connection = cn;
    cm.CommandType = CommandType.Text;
    cm.CommandText = "select call_id,call_status,member_id from WORLD_SERIES_CALL";

    da.SelectCommand = cm;
    da.Fill(ds, "test");
    GridView1.DataSource = ds;
    GridView1.DataBind();
    }
    catch { throw; }
    finally
    {
    cn = null;
    cm = null;
    }
    }

    protected void GridView1_PageIndexChanged(object sender, GridViewPageEventArgs e)
    {
    GridView1.PageIndex = e.NewPageIndex;
    BindData();
    }


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

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {


    string lblCALL_Id = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("lblCALL_ID")).Text;
    string lblCALL_STATUS = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("lblCALL_STATUS")).Text;
    string txtMEMBER_ID = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtMEMBER_ID")).Text;

    OracleConnection cn = new OracleConnection();
    OracleCommand cm = new OracleCommand();
    DataSet ds = new DataSet();
    OracleDataAdapter da = new OracleDataAdapter();
    try
    {
    cn.ConnectionString = "Data Source=MISC;User ID=SO;Password=SO";
    cn.Open();

    cm.Connection = cn;
    cm.CommandType = CommandType.Text;
    cm.CommandText = "UPDATE world_series_call SET"
    + "call_status ='" + lblCALL_STATUS + "'"
    + " WHERE call_id =" + lblCALL_Id + "";

    cm.ExecuteNonQuery();
    GridView1.DataBind();

    }
    catch { throw; }
    finally
    {
    cn=null;
    cm=null;
    }
    }
    private string _SortExpression;
    public string SortExpression
    {
    get { return _SortExpression; }
    set { _SortExpression = value; }
    }

    private string SortDirection
    {
    get { return ViewState["SortDirection"] as string ?? "ASC"; }
    set { ViewState["SortDirection"] = value; }
    }
    public void Gridview1_sorting(Object sender, System.Web.UI.WebControls.GridViewSortEventArgs e)
    {

    if (SortDirection == "ASC")
    {
    SortExpression = e.SortExpression.ToString();
    SortDirection = "DESC";
    }
    else
    {
    SortExpression = e.SortExpression.ToString();
    SortDirection = "ASC";
    }

    BindData();
    }

    }
     
    Bobby, Dec 11, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ropio

    GridView not updating

    ropio, Jul 12, 2006, in forum: Software
    Replies:
    0
    Views:
    1,160
    ropio
    Jul 12, 2006
  2. jm1468

    Gridview mapping

    jm1468, Jul 26, 2006, in forum: Software
    Replies:
    0
    Views:
    1,073
    jm1468
    Jul 26, 2006
  3. aidoCo
    Replies:
    2
    Views:
    17,972
  4. Usman

    Update and Delete From Gridview

    Usman, Nov 1, 2006, in forum: Software
    Replies:
    0
    Views:
    5,700
    Usman
    Nov 1, 2006
  5. visj4u

    DropdownList in gridview

    visj4u, Apr 27, 2007, in forum: Software
    Replies:
    0
    Views:
    1,246
    visj4u
    Apr 27, 2007
Loading...

Share This Page