newbie gridview question - how to autoupdate a field
am 23.01.2008 23:23:18 von mark
This is a multi-part message in MIME format.
------=_NextPart_000_000F_01C85DCB.7F9DEE60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a newbie question. I am showing the grid control bound to my =
database, but I want to automatically update a "last changed by" field =
whenever someone updates a record. I tried adding =
onrowupdated=3D"GridView_RowUpdated" to the gridview definition and then =
the following code but it just returns an error.=20
I also tried adding in the change to the "UpdateCommand" as:
UpdateCommand=3D"Update RefInfo SET=20
ServerTypeDesc=3D@ServerTypeDesc,
LastChangeID=3DChangerID,
WHERE ServerType=3D@ServerType">
but that just gives me an error as well. Can someone point out the =
proper way to do this?
Mark
Base code:
<%@ page language=3D"VB" %>
<%@ Import Namespace=3D"System.Data" %>
<%@ Import Namespace=3D"System.Data.SqlClient" %>
Simple GridView display of the REFINFO database
<%
dim ChangerID
ChangerID =3D Request.ServerVariables("LOGON_USER")
%>
ConnectionString=3D"<%$ ConnectionStrings:RWSqlConnectionString %>"
SelectCommand=3D"SELECT * FROM REFINFO"
UpdateCommand=3D"Update RefInfo SET=20
ServerTypeDesc=3D@ServerTypeDesc,
WHERE ServerType=3D@ServerType">
------=_NextPart_000_000F_01C85DCB.7F9DEE60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
charset=3Diso-8859-1">
I have a newbie question. I am showing =
the grid=20
control bound to my database, but I want to automatically update a "last =
changed=20
by" field whenever someone updates a record. I tried adding =20
onrowupdated=3D"GridView_RowUpdated" to the gridview =
definition=20
and then the following code but it just returns an error.
<script language=3D"VB" =
runat=3Dserver>
Sub=20
GridView_RowUpdated(ByVal sender As Object, ByVal e As=20
GridViewUpdatedEventArgs)
' finish the update process
sqlCmd =3D =
"Update=20
RefInfo set LastChangeID =3D ChangerID
End=20
Sub
</script>
I also tried adding in the change to =
the=20
"UpdateCommand" as:
size=3D2> =20
LastChangeID=3DChangerID,
WHERE
href=3D"">
size=3D2>ServerType=3D@ServerType
face=3DArial size=3D2>">
but that =
just gives me an=20
error as well. Can someone point out the proper way to do=20
this?
Mark
size=3D2>
size=3D2>
size=3D2>
Base code:
<%@ page language=3D"VB" =
%>
<%@ Import=20
Namespace=3D"System.Data" %>
<%@ Import =
Namespace=3D"System.Data.SqlClient"=20
%>
size=3D2><html>
<head>
=20
<title>Simple GridView display of the REFINFO=20
database</title>
</head>
<body>
<%
dim=20
ChangerID
ChangerID =
Request.ServerVariables("LOGON_USER")
%>
<asp:SqlDataSource =
ID=3D"RWRefInfoDB"=20
runat=3D"server"
ConnectionString=3D"<%$=20
ConnectionStrings:RWSqlConnectionString %>"
=20
SelectCommand=3D"SELECT * FROM REFINFO"
=20
UpdateCommand=3D"Update RefInfo SET
=
href=3D"mailto:ServerTypeDesc=3D@ServerTypeDesc">
size=3D2>ServerTypeDesc=3D@ServerTypeDesc
size=3D2>,
WHERE
href=3D"mailto:ServerType=3D@ServerType">
size=3D2>ServerType=3D@ServerType
size=3D2>">
</asp:SqlDataSource>
<form id=3D"form1"=20
runat=3D"server">
<asp:GridView=20
ID=3D"GridView"=20
=
DataSourceID=3D"RWRefInfoDB"=20
=20
runat=3D"server"
=20
AutoGenerateColumns=3D"False" =
=20
AutoGenerateEditButton=3D"True">
=20
<columns>
=
<asp:BoundField=20
DataField=3D"ServerType" HeaderText=3D"Type"=20
/>
<asp:BoundField=20
DataField=3D"ServerTypeDesc" HeaderText=3D"Server Type Long Name"=20
/>
</columns>
=20
</asp:GridView>
</form>
size=3D2></body>
</html>
------=_NextPart_000_000F_01C85DCB.7F9DEE60--
RE: newbie gridview question - how to autoupdate a field
am 24.01.2008 17:47:01 von Manish
Hi Mark,
Could you please let me know where this ChangeID coming from because you can
select any of the option for the ChangeID parameter where it is coming from
like control, Querystring and all.
Regards,
Manish
www.ComponentOne.com
"Mark" wrote:
> I have a newbie question. I am showing the grid control bound to my
> database, but I want to automatically update a "last changed by" field
> whenever someone updates a record. I tried adding
> onrowupdated="GridView_RowUpdated" to the gridview definition and then the
> following code but it just returns an error.
>
>
>
>
> I also tried adding in the change to the "UpdateCommand" as:
> UpdateCommand="Update RefInfo SET
> ServerTypeDesc=@ServerTypeDesc,
> LastChangeID=ChangerID,
> WHERE ServerType=@ServerType">
>
> but that just gives me an error as well. Can someone point out the proper
> way to do this?
> Mark
>
>
>
>
> Base code:
>
> <%@ page language="VB" %>
> <%@ Import Namespace="System.Data" %>
> <%@ Import Namespace="System.Data.SqlClient" %>
>
>
> Simple GridView display of the REFINFO database
>
>
> <%
> dim ChangerID
> ChangerID = Request.ServerVariables("LOGON_USER")
> %>
>
>
> ConnectionString="<%$ ConnectionStrings:RWSqlConnectionString %>"
> SelectCommand="SELECT * FROM REFINFO"
> UpdateCommand="Update RefInfo SET
> ServerTypeDesc=@ServerTypeDesc,
> WHERE ServerType=@ServerType">
>
>
>
>
>
>
Re: newbie gridview question - how to autoupdate a field
am 24.01.2008 19:56:16 von mark
Manish,
I am just writing code in notepad to do all of this.
The variable ChangerID is the logon credentials of the person visiting the
website. It is extracted at the top of the code via the ASP code:
ChangerID = Request.ServerVariables("LOGON_USER")
essentially I want to put into the database the id of whoever made the
change but I can't figure out how to code the GridView so that when someone
updates something it not only updates the data table with the changes made
via the gridview but also the variable.
any help would be greatly appreciated!
Mark
"Manish" wrote in message
news:C531893F-08D2-46F6-9BD5-C1E4EBD908C6@microsoft.com...
> Hi Mark,
>
> Could you please let me know where this ChangeID coming from because you
> can
> select any of the option for the ChangeID parameter where it is coming
> from
> like control, Querystring and all.
>
> Regards,
> Manish
> www.ComponentOne.com
>
> "Mark" wrote:
>
>> I have a newbie question. I am showing the grid control bound to my
>> database, but I want to automatically update a "last changed by" field
>> whenever someone updates a record. I tried adding
>> onrowupdated="GridView_RowUpdated" to the gridview definition and then
>> the
>> following code but it just returns an error.
>>
>>
>>
>>
>> I also tried adding in the change to the "UpdateCommand" as:
>> UpdateCommand="Update RefInfo SET
>> ServerTypeDesc=@ServerTypeDesc,
>> LastChangeID=ChangerID,
>> WHERE ServerType=@ServerType">
>>
>> but that just gives me an error as well. Can someone point out the proper
>> way to do this?
>> Mark
>>
>>
>>
>>
>> Base code:
>>
>> <%@ page language="VB" %>
>> <%@ Import Namespace="System.Data" %>
>> <%@ Import Namespace="System.Data.SqlClient" %>
>>
>>
>> Simple GridView display of the REFINFO database
>>
>>
>> <%
>> dim ChangerID
>> ChangerID = Request.ServerVariables("LOGON_USER")
>> %>
>>
>>
>> ConnectionString="<%$ ConnectionStrings:RWSqlConnectionString %>"
>> SelectCommand="SELECT * FROM REFINFO"
>> UpdateCommand="Update RefInfo SET
>> ServerTypeDesc=@ServerTypeDesc,
>> WHERE ServerType=@ServerType">
>>
>>
>>
>>
>>
>>