mountainbiking
02-05-2007, 07:07 AM
How do I go about obtaining the value of a textbox in DetailsView so I can properly execute my AccessDataSource updatecommand.
Since the textboxes are generated dynamically by the DetailsView I figured I would do what I have done in the past and use @Description for example to grab the values in the textbox for a given field.
This works fine on one DetailsView but not the other one that I am using... See below my code for the AccessDataSource update command and the DetailsView:
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateDeleteButton="True"
AutoGenerateRows="False" DataSourceID="AccessDataSource3" Height="50px" Width="125px" DataKeyNames="ID" AutoGenerateInsertButton="True" AutoGenerateEditButton="True" OnItemCommand="DetailsView1_ItemCommand" OnItemUpdating="DetailsView1_ItemUpdating" OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Updated_By" HeaderText="Updated_By" SortExpression="Updated_By" />
<asp:BoundField DataField="Update_Date" HeaderText="Update_Date" SortExpression="Update_Date" />
<asp:BoundField DataField="Last_Update" HeaderText="Last_Update" SortExpression="Last_Update" />
<asp:BoundField DataField="Last_Date" HeaderText="Last_Date" SortExpression="Last_Date" />
<asp:BoundField DataField="fullname" HeaderText="fullname" SortExpression="fullname" />
</Fields>
</asp:DetailsView>
UpdateCommand="UPDATE tblAnswers SET Description=@Description, Last_Date=Now() WHERE ID=@ID"
If I were to use this
UpdateCommand="UPDATE tblAnswers SET Description='Test', Last_Date=Now() WHERE ID=@ID"
the update statement would work fine.
Since the textboxes are generated dynamically by the DetailsView I figured I would do what I have done in the past and use @Description for example to grab the values in the textbox for a given field.
This works fine on one DetailsView but not the other one that I am using... See below my code for the AccessDataSource update command and the DetailsView:
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateDeleteButton="True"
AutoGenerateRows="False" DataSourceID="AccessDataSource3" Height="50px" Width="125px" DataKeyNames="ID" AutoGenerateInsertButton="True" AutoGenerateEditButton="True" OnItemCommand="DetailsView1_ItemCommand" OnItemUpdating="DetailsView1_ItemUpdating" OnModeChanging="DetailsView1_ModeChanging">
<Fields>
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="Updated_By" HeaderText="Updated_By" SortExpression="Updated_By" />
<asp:BoundField DataField="Update_Date" HeaderText="Update_Date" SortExpression="Update_Date" />
<asp:BoundField DataField="Last_Update" HeaderText="Last_Update" SortExpression="Last_Update" />
<asp:BoundField DataField="Last_Date" HeaderText="Last_Date" SortExpression="Last_Date" />
<asp:BoundField DataField="fullname" HeaderText="fullname" SortExpression="fullname" />
</Fields>
</asp:DetailsView>
UpdateCommand="UPDATE tblAnswers SET Description=@Description, Last_Date=Now() WHERE ID=@ID"
If I were to use this
UpdateCommand="UPDATE tblAnswers SET Description='Test', Last_Date=Now() WHERE ID=@ID"
the update statement would work fine.