Stan,
It did but I'm getting message that says:
Index was out of range. Must be non-negative and less than the size of the
collection.
Parameter name: index
Also e.NewValue(0) start with Vendor_name not vendor_Id which was Cell(1)
Thanks,
Ed Dror
On 21 Mar, 19:38, "Ed Dror" <e...@andrewlauren.com> wrote:
> Hi there,
>
[quoted text clipped - 38 lines]
> Thanks,
> Ed Dror
Hi
The GridView rows cannot be relied upon to contain valid data during
the RowUpdated event. An SQL update command will have been executed by
the DataSource but the GridView rows are not refreshed until later.
Use the NewValues property of the GridViewUpdatedEventArgs parameter
'e' instead:
Label1.Text = e.NewValues(0)
Label2.Text = e.NewValues(1)
and so on
HTH
Stan - 21 Mar 2008 23:39 GMT
> Stan,
>
[quoted text clipped - 7 lines]
> Thanks,
> Ed Dror
Ed
A better way to access the data is to use column names. I suggested a
method using index values because no column names were given. So for
example
Label1.Text = e.NewValues("vendor_id")
Steven Cheng - 24 Mar 2008 03:58 GMT
Hi Ed,
I agree with Stan that it would be better to use the "NewValues" collection
in RowUpdated event. You can loop through all updated column values through
the following code:
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs
e)
{
foreach (object key in e.NewValues.Keys)
{
Response.Write("<br/>" + key + ": " + e.NewValues[key]);
}
}
Also, "GridView.SelectedRow" is not useful here. "SelectedRow" point to the
currently selectedrow, it is not the currently edited or updated row.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Ed Dror" <edd@andrewlauren.com>
>References: <ejhwwq4iIHA.4684@TK2MSFTNGP06.phx.gbl>
<4e65ec7a-65dd-4654-9b28-17dbee7ce1f5@s37g2000prg.googlegroups.com>
>Subject: Re: GridView1_RowUpdated problem
>Date: Fri, 21 Mar 2008 13:54:07 -0700
>Stan,
>
[quoted text clipped - 67 lines]
>
>HTH
Ed Dror - 24 Mar 2008 20:27 GMT
Steven,
All that is good but I want to include the Vendor_ID which is not showing
I tried e.NewValue("Vendor_ID") with no result (Because is PK)
when you use on selected item changed
Label1.Text = GridView1.SelectedRow.Cells(1).Text
It will show the ID but all the rest is blanc
I could let the end users click "SE:ECT" and then "EDIT" but I don't do that
Less user type is more productive for me.
Thanks,
Ed Dror
> Hi Ed,
>
[quoted text clipped - 113 lines]
>>
>>HTH
Steven Cheng - 25 Mar 2008 03:19 GMT
Thanks for your reply Ed,
Yes, using Cell[id].Text is not quite reliable since the result may change
due to the GridView column type or the current row mode. So the problem
now is to get the primary key, have you tried using the GridView.DatdaKeys
+ GridView.EditIndex to get the key of the editing row? e.g.
==============
protected void GridView1_RowUpdated(object sender,
GridViewUpdatedEventArgs e)
{
Response.Write("<br/>NewValues: ");
foreach (object key in e.NewValues.Keys)
{
Response.Write("<br/>" + key + ": " + e.NewValues[key]);
}
Response.Write("<br/>OldValues: ");
foreach (object key in e.OldValues.Keys)
{
Response.Write("<br/>" + key + ": " + e.OldValues[key]);
}
Response.Write("<br/>Keys: " +
GridView1.DataKeys[GridView1.EditIndex].Value);
}
===================
Thus, you can get all the fields' value you want.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Ed Dror" <edd@andrewlauren.com>
>References: <ejhwwq4iIHA.4684@TK2MSFTNGP06.phx.gbl>
<4e65ec7a-65dd-4654-9b28-17dbee7ce1f5@s37g2000prg.googlegroups.com>
<#caqSV5iIHA.2084@TK2MSFTNGP02.phx.gbl>
<vt0BvrVjIHA.4200@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: GridView1_RowUpdated problem
>Date: Mon, 24 Mar 2008 12:27:07 -0700
>Steven,
>
[quoted text clipped - 131 lines]
>>>
>>>HTH
Ed Dror - 25 Mar 2008 18:51 GMT
Steven,
It works...
Label1.Text = GridView1.DataKeys(GridView1.EditIndex).Value
This will give me the VendorID exactlly what I want
Thank you very mutch
Ed Dror
> Thanks for your reply Ed,
>
[quoted text clipped - 191 lines]
>>>>
>>>>HTH
Steven Cheng - 26 Mar 2008 01:56 GMT
Thanks for your reply Ed,
I'm glad that it helps you.
Have a good day!
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Ed Dror" <edd@andrewlauren.com>
>Subject: Re: GridView1_RowUpdated problem
>Date: Tue, 25 Mar 2008 10:51:18 -0700
>Steven,
>
[quoted text clipped - 201 lines]
>>>>>
>>>>>HTH