DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Wed, 11 Jul 2007 16:31:23 -0700,    posted on: microsoft.public.dotnet.framework.aspnet.datagridcontrol        back       

Thread Index
  1    ah


Re: GridView, DataSource, RowUpdating, e.OldValues and e.NewValues   
hi,

thanks a lot for the rowupdating.it working fine.but if i use this code
for customer database.after i clicking the update button im getting
errors .actually im new to this .net plz solve my problem.
here's my code
 public  void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataTable table = new DataTable("customers");
            Session["Table"] = table;

            string connectionstring =
"server=.;database=Northwind;uid=sa;pwd=";
            string commandtext;
            commandtext = "select * from customers ";
            SqlConnection myconnection = new
SqlConnection(connectionstring);
            SqlDataAdapter mycommand = new SqlDataAdapter(commandtext,
myconnection);
            DataSet ds = new DataSet();

            mycommand.Fill(table);

            GridView1.DataSource = table;
            GridView1.DataBind();



        }
    }
protected void GridView1_RowUpdating(object sender,
GridViewUpdateEventArgs e)
    {

        DataTable dataTable = Session["Table"] as DataTable;

        for (int i = 0; i < dataTable.Columns.Count; i++)
        {
            DataControlFieldCell
                    cell = GridView1.Rows[e.RowIndex].Cells[i] as
DataControlFieldCell;
            GridView1.Columns[i].ExtractValuesFromCell(e.NewValues,
cell, DataControlRowState.Edit, true);
        }


        foreach (string key in e.NewValues.Keys)
        {
            //response.write("<br/>" + key + ": " + e.NewValues[key]);
            dataTable.Rows[e.RowIndex][key] = e.NewValues[key];
        }

        GridView1.EditIndex = -1;
        Session["Table"] = dataTable;
        GridView1.DataSource = dataTable;
        GridView1.DataBind();
    }
error is in this line:
 DataControlFieldCell cell = GridView1.Rows[e.RowIndex].Cells[i] as
DataControlFieldCell;

error is:
Specified argument was out of the range of valid values.
Parameter name: index
plz tel me
thanks

*** Sent via Developersdex http://www.developersdex.com ***
Date:Wed, 11 Jul 2007 16:31:23 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us