M
Mark
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.
<script language="VB" runat=server>
Sub GridView_RowUpdated(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)
' finish the update process
sqlCmd = "Update RefInfo set LastChangeID = ChangerID
End Sub
</script>
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" %>
<html>
<head>
<title>Simple GridView display of the REFINFO database</title>
</head>
<body>
<%
dim ChangerID
ChangerID = Request.ServerVariables("LOGON_USER")
%>
<asp:SqlDataSource ID="RWRefInfoDB" runat="server"
ConnectionString="<%$ ConnectionStrings:RWSqlConnectionString %>"
SelectCommand="SELECT * FROM REFINFO"
UpdateCommand="Update RefInfo SET
ServerTypeDesc=@ServerTypeDesc,
WHERE ServerType=@ServerType">
</asp:SqlDataSource>
<form id="form1" runat="server">
<asp:GridView
ID="GridView"
DataSourceID="RWRefInfoDB"
runat="server"
AutoGenerateColumns="False"
AutoGenerateEditButton="True">
<columns>
<asp:BoundField DataField="ServerType" HeaderText="Type" />
<asp:BoundField DataField="ServerTypeDesc" HeaderText="Server Type Long Name" />
</columns>
</asp:GridView>
</form>
</body>
</html>
<script language="VB" runat=server>
Sub GridView_RowUpdated(ByVal sender As Object, ByVal e As GridViewUpdatedEventArgs)
' finish the update process
sqlCmd = "Update RefInfo set LastChangeID = ChangerID
End Sub
</script>
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" %>
<html>
<head>
<title>Simple GridView display of the REFINFO database</title>
</head>
<body>
<%
dim ChangerID
ChangerID = Request.ServerVariables("LOGON_USER")
%>
<asp:SqlDataSource ID="RWRefInfoDB" runat="server"
ConnectionString="<%$ ConnectionStrings:RWSqlConnectionString %>"
SelectCommand="SELECT * FROM REFINFO"
UpdateCommand="Update RefInfo SET
ServerTypeDesc=@ServerTypeDesc,
WHERE ServerType=@ServerType">
</asp:SqlDataSource>
<form id="form1" runat="server">
<asp:GridView
ID="GridView"
DataSourceID="RWRefInfoDB"
runat="server"
AutoGenerateColumns="False"
AutoGenerateEditButton="True">
<columns>
<asp:BoundField DataField="ServerType" HeaderText="Type" />
<asp:BoundField DataField="ServerTypeDesc" HeaderText="Server Type Long Name" />
</columns>
</asp:GridView>
</form>
</body>
</html>