ASP.NET UpdateCommand replace E_UID with U_UID - sql

I know this is simply a SQL question but I can't remember in ASP.NET how to make this work, keep getting UID column not there error.
want to get the value of UsersDataTbl.UID and UPDATE EnrollmentsTbl.UID
<asp:GridView ID="GridView3" runat="server" AllowSorting="True" AutoGenerateColumns="True"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3"
DataKeyNames="AutoNum" DataSourceID="AccessDataSource3" ForeColor="Black" GridLines="Vertical"
AutoGenerateEditButton="true" AutoGenerateDeleteButton="false">
<FooterStyle BackColor="#CCCCCC" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#6699CC" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource3" runat="server"
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
DeleteCommand="DELETE FROM [EnrollmentsTbl] WHERE [AutoNum] = ?"
SelectCommand="SELECT EnrollmentsTbl.AutoNum, EnrollmentsTbl.UID As E_UID, UsersDataTbl.UID As U_UID,
UsersDataTbl.LastName, UsersDataTbl.FirstName FROM EnrollmentsTbl INNER JOIN UsersDataTbl
ON EnrollmentsTbl.UserName = UsersDataTbl.UserName"
UpdateCommand="UPDATE [EnrollmentsTbl] SET E_UID = ? WHERE [AutoNum] = ?">
<DeleteParameters>
<asp:Parameter Name="AutoNum" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="E_UID" Type="Int32" />
<asp:Parameter Name="AutoNum" Type="Int32" />
</UpdateParameters>
</asp:AccessDataSource>
the error I get is: Exception Details: System.Data.OleDb.OleDbException: Cannot update 'E_UID'; field not updateable.

Related

move AccessDataSource to code behind in vb

Looking to convert dozens of pages from aspx AccessDataSource to vb.net code behind. I'm using OleDB and ADO on other pages. wanted to know if there is any canned code to bind a simple select statement to the GridView1
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="AccessDataSource1" BackColor="White" BorderColor="#999999"
BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black"
GridLines="Vertical" AllowSorting="True">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="RowLevelCheckBox" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UsersDataTbl.LastName" HeaderText="Last Name" SortExpression="LastName" />
<asp:BoundField DataField="UsersDataTbl.FirstName" HeaderText="First Name" SortExpression="FirstName" />
<asp:BoundField DataField="UsersDataTbl.Affiliation" HeaderText="Affiliation" SortExpression="Affiliation" />
<asp:BoundField DataField="UsersDataTbl.UID" HeaderText="UID" SortExpression="UID" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#6699CC" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
SelectCommand="SELECT [UsersDataTbl.LastName], [UsersDataTbl.FirstName], [UsersDataTbl.Affiliation], [UsersDataTbl.UID], [ALSProviders.ALS]
FROM [UsersDataTbl] LEFT JOIN [ALSProviders] ON (UsersDataTbl.UID = ALSProviders.UID) WHERE [UsersDataTbl.Career] = True
AND [UsersDataTbl.Active] = True AND ([UsersDataTbl.UID] NOT IN (SELECT UID FROM [ALSProviders]))
ORDER BY [UsersDataTbl.LastName]" >
<SelectParameters>
</SelectParameters>
</asp:AccessDataSource>

Why isn't my GridView updating?

I'm trying to update the 'question' field when I hit the 'update' button for a specific row. I am able to change the text when I hit the 'edit' button, but when I hit the 'update' button it reverts back to its original value. Nothing is changed in the database either.
Here is my markup:
<div class="divGrid" style="margin: 0 auto; width: 70%;">
<asp:GridView ID="QuestionsGridView" CssClass="gridView" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Width="100%" CellPadding="4" ForeColor="#333333">
<Columns>
<asp:BoundField DataField="QUESTION_NUMBER" ReadOnly="true" HeaderText="Question Number" SortExpression="QUESTION_NUMBER" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Question" SortExpression="QUESTION" HeaderStyle-HorizontalAlign="Center">
<EditItemTemplate>
<asp:TextBox ID="EditQuestionBox" runat="server" Height="50px" Text='<%# Bind("QUESTION") %>' TextMode="MultiLine" Width="99%" CssClass="multilineTBox" Columns="1" Rows="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("QUESTION") %>'></asp:Label>
</ItemTemplate>
<ControlStyle Width="99%" />
</asp:TemplateField>
<asp:BoundField DataField="CAT_NAME" ReadOnly="true" HeaderText="Category" SortExpression="CAT_NAME" HeaderStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="QUES_ORDER" ReadOnly="true" HeaderText="Order in Category" SortExpression="QUES_ORDER" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
<asp:CommandField CausesValidation="False" HeaderText="Edit" ShowEditButton="True" ControlStyle-Width="4em" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#a0a0a0" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" HorizontalAlign="Center" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#ffffff" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Corp_TaxConnectionString %>"
SelectCommand="SELECT tq.id, tq.question, tq.ques_order, tc.cat_name, tq.question_number FROM t01_tax_questions AS tq INNER JOIN t01_tax_categories AS tc ON tq.category = tc.cat_order ORDER BY tq.question_number"
UpdateCommand="UPDATE t01_tax_questions SET question = #question WHERE question_number = #question_number">
<UpdateParameters>
<asp:Parameter Name="question_number" Type="Int32" />
<asp:Parameter Name="question" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
And the table:
SQLServer Table
EDIT:
After looking, in my EditItemTemplate, I bind the question to the textbox. Is it possible that after I click the update button that the original question is databound to the textbox again before it tries to update? If this is the case, how would I get around that?
After looking further into it, I realized I had forgotten the apparently very important "DataKeyNames" attribute in my GridView tag. I feel really dumb. Here is the new working code.
<div class="divGrid" style="margin: 0 auto; width: 70%;">
<asp:GridView ID="QuestionsGridView" CssClass="gridView" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyNames="ID, QUESTION_NUMBER" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="question_number" HeaderText="Question Number" SortExpression="question_number" ReadOnly="True" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="question" HeaderText="Question" SortExpression="question" >
<ControlStyle Width="100%" Height="80%" />
</asp:BoundField>
<asp:BoundField DataField="cat_name" HeaderText="Category" SortExpression="cat_name" ItemStyle-HorizontalAlign="Center">
<ControlStyle Height="80%" />
</asp:BoundField>
<asp:BoundField DataField="ques_order" HeaderText="Question Order" SortExpression="ques_order" ReadOnly="True" ItemStyle-HorizontalAlign="Center" />
<asp:CommandField HeaderText="Edit" ShowEditButton="True" CausesValidation="False" HeaderStyle-Width="4%" ItemStyle-HorizontalAlign="Center"/>
<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" CausesValidation="False" HeaderStyle-Width ="4%" ItemStyle-HorizontalAlign="Center" />
</Columns>
<EditRowStyle BackColor="Yellow" Width="100%" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#a0a0a0" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" HorizontalAlign="Center" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#ffffff" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Corp_TaxConnectionString %>" SelectCommand="SELECT
tq.id, tq.question_number, tq.question, tc.cat_name, tq.ques_order
FROM
t01_tax_questions AS tq
INNER JOIN
t01_tax_categories AS tc
ON
tq.category = tc.cat_order
ORDER BY tq.question_number"
DeleteCommand="DELETE
FROM
t01_tax_questions
WHERE
question_number = #question_number"
UpdateCommand="UPDATE
t01_tax_questions
SET
question = #question
WHERE
id = #id">
<DeleteParameters>
<asp:Parameter Name="#question_number" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="#question"/>
<asp:Parameter Name="#id" />
</UpdateParameters>
</asp:SqlDataSource>
It is all explained in this MSDN Documentation
Thank you to all who looked at this and tried.

How to find average of two gridviews in sql vb.net

I have two GridView1 and GridView2 which give a numerical values I want to create another Gridview3 or functionality that can generate the average of both the values of the existing Gridview1 & GridView2 i.e. GridView3=(GridView1+GridView2)/2
How should I write the SQL statement for it.
This is my GridView code in aspx
<asp:GridView ID="GridView7" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataSourceID="SqlDataSource9" ForeColor="Black" GridLines="None">
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>
<asp:BoundField DataField="mean_POLQA_score" HeaderText="mean_POLQA_score" ReadOnly="True" SortExpression="mean_POLQA_score" />
</Columns>
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
<SortedAscendingCellStyle BackColor="#FAFAE7" />
<SortedAscendingHeaderStyle BackColor="#DAC09E" />
<SortedDescendingCellStyle BackColor="#E1DB9C" />
<SortedDescendingHeaderStyle BackColor="#C2A47B" />
</asp:GridView>
The SQL queries are as follows
SELECT ROUND(AVG(POLQA_Score),3) AS mean_POLQA_score FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?
SELECT ROUND(AVG(POLQA_Score),3) AS mean_POLQA_score1 FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?

No value given for one or more required parameters. System.Data.OleDb.OleDbException:

I am getting this error while running my aspx file when I click o Button2 after selecting start and end date and value from dropdown list.
The website was working normally but now it is throwing this exception.
My Aspx code is as follows
<center><p style="color: #000000; font-weight: bold;">
START DATE AND TIME <asp:TextBox ID="TextBox3" runat="server" Width="181px" BorderColor="Black" BorderStyle="Solid"></asp:TextBox> <img src="calender.png" /></p></center>
<center> <p style="color: #000000; font-weight: bold;">
END DATE AND TIME <asp:TextBox ID="TextBox2" runat="server" Width="188px" BorderColor="Black" BorderStyle="Solid"></asp:TextBox> <img src="calender.png" />
</p>
</center>
<br />
<center style="height: 40px"> <asp:Button ID="Button2" runat="server" Text="SUBMIT AND CALCULATE" onclick="btnSave_Click1" BackColor="#FF9966" CssClass="btn btn-large" Font-Bold="True"/>
<br />
<td>
<asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="False" CellPadding="3" DataSourceID="SqlDataSource5" Height="146px" Width="53px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellSpacing="2">
<Columns>
<asp:BoundField DataField="stdev_POLQA_score" HeaderText="stdev_POLQA_score" ReadOnly="True" SortExpression="stdev_POLQA_score" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView></td></tr></table>
<br />
<asp:Button ID="Button4" runat="server" BackColor="#FF9966" Text="EXPORT POLQA TO EXCEL" CssClass="btn btn-large" Font-Bold="True" />
<br />
<br />
<table><tr> <td>
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource3" Height="146px" Width="53px" ForeColor="Black" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="mean_RTD" HeaderText="mean_RTD" ReadOnly="True" SortExpression="mean_RTD" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="White" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView></td>
<br /><td>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" DataSourceID="SqlDataSource4" Height="146px" Width="53px" ForeColor="Black" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="STDEV_RTD" HeaderText="stdev_RTD" ReadOnly="True" SortExpression="STDEV_RTD" >
<ItemStyle Font-Bold="True" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="Black" HorizontalAlign="Right" BackColor="White" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
</asp:GridView></td>
<br />
</tr> </table>
</center>
<br />
<center> <asp:Button ID="Button3" runat="server" Text="EXPORT RTD TO EXCEL" onclick="Button3_Click" BackColor="#FF9966" CssClass="btn btn-large" Font-Bold="True" Width="257px"/>
</center>
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(AVG(POLQA_Score),3) AS mean_POLQA_score FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(AVG(RTD),3) AS mean_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT * FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuadPhone_ID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(Stdev(RTD),3) AS STDEV_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND? AND RTD>0 AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT * FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT ROUND(Stdev(POLQA_score),3) AS stdev_POLQA_score FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID=?">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<br />
<div style="display:none" ><center> <asp:GridView ID="GridView5" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource6" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="VQT_Timestamp" HeaderText="VQT_Timestamp" SortExpression="VQT_Timestamp" />
<asp:BoundField DataField="VQuad_Timestamp" HeaderText="VQuad_Timestamp" SortExpression="VQuad_Timestamp" />
<asp:BoundField DataField="GPS_Position" HeaderText="GPS_Position" SortExpression="GPS_Position" />
<asp:BoundField DataField="GPS_Lat" HeaderText="GPS_Lat" SortExpression="GPS_Lat" />
<asp:BoundField DataField="GPS_Long" HeaderText="GPS_Long" SortExpression="GPS_Long" />
<asp:BoundField DataField="VQuad_CallID" HeaderText="VQuad_CallID" SortExpression="VQuad_CallID" />
<asp:BoundField DataField="VQuad_Location" HeaderText="VQuad_Location" SortExpression="VQuad_Location" />
<asp:BoundField DataField="VQuad_PhoneID" HeaderText="VQuad_PhoneID" SortExpression="VQuad_PhoneID" />
<asp:BoundField DataField="Degraded" HeaderText="Degraded" SortExpression="Degraded" />
<asp:BoundField DataField="Deg_File_Name" HeaderText="Deg_File_Name" SortExpression="Deg_File_Name" />
<asp:BoundField DataField="POLQA_Score" HeaderText="POLQA_Score" SortExpression="POLQA_Score" />
<asp:BoundField DataField="Pass_Or_Fail" HeaderText="Pass_Or_Fail" SortExpression="Pass_Or_Fail" />
<asp:BoundField DataField="Jitter_Min" HeaderText="Jitter_Min" SortExpression="Jitter_Min" />
<asp:BoundField DataField="Jitter_Max" HeaderText="Jitter_Max" SortExpression="Jitter_Max" />
<asp:BoundField DataField="Jitter_Ave" HeaderText="Jitter_Ave" SortExpression="Jitter_Ave" />
<asp:BoundField DataField="EModel_Polqa" HeaderText="EModel_Polqa" SortExpression="EModel_Polqa" />
<asp:BoundField DataField="Speech_Level_Diff" HeaderText="Speech_Level_Diff" SortExpression="Speech_Level_Diff" />
<asp:BoundField DataField="SNR_Diff" HeaderText="SNR_Diff" SortExpression="SNR_Diff" />
<asp:BoundField DataField="ASR_Ref" HeaderText="ASR_Ref" SortExpression="ASR_Ref" />
<asp:BoundField DataField="ASR_Deg" HeaderText="ASR_Deg" SortExpression="ASR_Deg" />
<asp:BoundField DataField="Number_of_Utterance" HeaderText="Number_of_Utterance" SortExpression="Number_of_Utterance" />
<asp:BoundField DataField="Call_Timestamp" HeaderText="Call_Timestamp" SortExpression="Call_Timestamp" />
<asp:BoundField DataField="CallType_Orig" HeaderText="CallType_Orig" SortExpression="CallType_Orig" />
<asp:BoundField DataField="CallType_Term" HeaderText="CallType_Term" SortExpression="CallType_Term" />
</Columns>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView></center></div>
<br />
<div style="display:none"><center><asp:GridView ID="GridView6" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource7">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="VQuad_Timestamp" HeaderText="VQuad_Timestamp" SortExpression="VQuad_Timestamp" />
<asp:BoundField DataField="GPS_Position" HeaderText="GPS_Position" SortExpression="GPS_Position" />
<asp:BoundField DataField="GPS_Lat" HeaderText="GPS_Lat" SortExpression="GPS_Lat" />
<asp:BoundField DataField="GPS_Long" HeaderText="GPS_Long" SortExpression="GPS_Long" />
<asp:BoundField DataField="AFT" HeaderText="AFT" SortExpression="AFT" />
<asp:BoundField DataField="RTD" HeaderText="RTD" SortExpression="RTD" />
<asp:BoundField DataField="RTD_Error" HeaderText="RTD_Error" SortExpression="RTD_Error" />
<asp:BoundField DataField="PDD" HeaderText="PDD" SortExpression="PDD" />
<asp:BoundField DataField="PDD_Error" HeaderText="PDD_Error" SortExpression="PDD_Error" />
<asp:BoundField DataField="Phone_ID" HeaderText="Phone_ID" SortExpression="Phone_ID" />
<asp:BoundField DataField="Call_Control_Event" HeaderText="Call_Control_Event" SortExpression="Call_Control_Event" />
<asp:BoundField DataField="VQuad_CallID" HeaderText="VQuad_CallID" SortExpression="VQuad_CallID" />
<asp:BoundField DataField="VQuad_Location" HeaderText="VQuad_Location" SortExpression="VQuad_Location" />
<asp:BoundField DataField="VQuad_PhoneID" HeaderText="VQuad_PhoneID" SortExpression="VQuad_PhoneID" />
<asp:BoundField DataField="Call_Timestamp" HeaderText="Call_Timestamp" SortExpression="Call_Timestamp" />
<asp:BoundField DataField="RTD_Rating" HeaderText="RTD_Rating" SortExpression="RTD_Rating" />
<asp:BoundField DataField="OWD" HeaderText="OWD" SortExpression="OWD" />
<asp:BoundField DataField="SWR" HeaderText="SWR" SortExpression="SWR" />
<asp:BoundField DataField="CC_Condition" HeaderText="CC_Condition" SortExpression="CC_Condition" />
<asp:BoundField DataField="CallType_Orig" HeaderText="CallType_Orig" SortExpression="CallType_Orig" />
<asp:BoundField DataField="CallType_Term" HeaderText="CallType_Term" SortExpression="CallType_Term" />
</Columns>
</asp:GridView></center></div>
<br />
<br />
<asp:AccessDataSource runat="server" DataFile="C:\Users\saishnib\Desktop\VQT DB LATEST ORIGINAL (copy)\New folder\VQT.mdb" SelectCommand="SELECT AVG(POLQA_Score) AS MEANPOLQA FROM VQTPOLQA WHERE (VQT_Timestamp BETWEEN ? AND ?)">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox3" DefaultValue="" Name="?" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="?" PropertyName="Text" />
</SelectParameters>
</asp:AccessDataSource>
<br />
<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VQTConnectionString %>" ProviderName="<%$ ConnectionStrings:VQTConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT [VQuad_PhoneID] FROM [VQTPOLQA]"></asp:SqlDataSource>
<br />
My aspx.vb code is as follows
Protected Sub btnSave_Click1(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Dim connectionString As [String] = "Provider=Microsoft.ACE.OLEDB.12.0;Data" + " Source=C:\Users\saishnib\Desktop\VQT DB LATEST ORIGINAL (copy)\New folder\VQT.mdb"
Dim ds As New DataSet()
Dim conn As New OleDbConnection(connectionString)
conn.Open()
Dim cmd As New OleDbCommand("SELECT ROUND(AVG(POLQA_Score),3) AS MEANPOLQA FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? AND VQuad_PhoneID =?", conn)
Dim cmd2 As New OleDbCommand("SELECT ROUND(AVG(RTD),3) AS mean_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 AND VQuad_PhoneID=?", conn)
Dim cmd3 As New OleDbCommand("SELECT Stdev(RTD) AS STDEV_RTD FROM VQuadData WHERE VQuad_Timestamp BETWEEN ? AND ? AND RTD>0 VQuad_PhoneID =?", conn)
Dim cmd4 As New OleDbCommand("SELECT Stdev(POLQA_Score) AS STDEV_POLQA FROM VQTPOLQA WHERE VQT_Timestamp BETWEEN ? AND ? VQuad_PhoneID =?", conn)
Dim param As OleDbParameter
param = cmd.CreateParameter
param.OleDbType = OleDbType.Date
param.Value = DateTime.Parse(TextBox3.Text)
param.ParameterName = "#StartDate"
cmd.Parameters.Add(param)
Dim param1 As OleDbParameter
param1 = cmd.CreateParameter
param1.OleDbType = OleDbType.Date
param1.Value = DateTime.Parse(TextBox2.Text)
param1.ParameterName = "#EndDate"
cmd.Parameters.Add(param1)
GridView1.DataBind()
Dim param2 As OleDbParameter
param2 = cmd2.CreateParameter
param2.OleDbType = OleDbType.Date
param2.Value = DateTime.Parse(TextBox3.Text)
param2.ParameterName = "#StartDate"
cmd2.Parameters.Add(param2)
Dim param3 As OleDbParameter
param3 = cmd2.CreateParameter
param3.OleDbType = OleDbType.Date
param3.Value = DateTime.Parse(TextBox2.Text)
param3.ParameterName = "#EndDate"
cmd2.Parameters.Add(param3)
GridView2.DataBind()
Dim param4 As OleDbParameter
param4 = cmd3.CreateParameter
param4.OleDbType = OleDbType.Date
param4.Value = DateTime.Parse(TextBox3.Text)
param4.ParameterName = "#StartDate"
cmd3.Parameters.Add(param4)
Dim param5 As OleDbParameter
param5 = cmd3.CreateParameter
param5.OleDbType = OleDbType.Date
param5.Value = DateTime.Parse(TextBox2.Text)
param5.ParameterName = "#EndDate"
cmd3.Parameters.Add(param5)
GridView3.DataBind()
Dim param6 As OleDbParameter
param6 = cmd4.CreateParameter
param6.OleDbType = OleDbType.Date
param6.Value = DateTime.Parse(TextBox3.Text)
param6.ParameterName = "#StartDate"
cmd4.Parameters.Add(param6)
Dim param7 As OleDbParameter
param7 = cmd4.CreateParameter
param7.OleDbType = OleDbType.Date
param7.Value = DateTime.Parse(TextBox2.Text)
param7.ParameterName = "#EndDate"
cmd4.Parameters.Add(param7)
GridView4.DataBind()
conn.Close()
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView6.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
Return
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView5.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
End Class
After editing the SQL DATA source that is attached to the particular GridView we can modify the ? content to be Control TextBox and DropDown by using the ideal SQL query this solves the issue.

Updating SQL database using gridview/templatefield

Anybody know how to get a Templatefield column of text-boxes to feed data typed into them back into a sql database using the SqlDataSource already being used in the gridview the templatefield is in and a buttonfield using an update function? I was just wondering if anybody has any idea how to get this to work because I haven't been able to find any way of doing this.
Please let me know if any of you need any more information to help you solve this dilemma.
I am able to get the information to feed back into the SQL server if i enable edit and change the information in the textbox as well as another column's field in the same row, but it won't update if I only change the information in the textbox whether in edit mode or just clicking the update button.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<center>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Brdcst_Nbr" DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display." Width="657px">
<Columns>
<asp:BoundField DataField="Brdcst_Nbr" HeaderText="Brdcst_Nbr" ReadOnly="True"
SortExpression="Brdcst_Nbr" />
<asp:BoundField DataField="Item_Nbr" HeaderText="Item_Nbr"
SortExpression="Item_Nbr" ReadOnly="True" />
<asp:CheckBoxField DataField="IsPicked" HeaderText="IsPicked"
SortExpression="IsPicked" />
<asp:TemplateField SortExpression="Row" HeaderText="Row">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Mode="twoway" AutoPostBack="true" CausesValidation="true" Text='<%# Bind("Row") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Mode="twoway" AutoPostBack="true" CausesValidation="true" Text='<%# Bind("Row") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField ButtonType="Button" CommandName="Update" Text="Update" />
<asp:ButtonField ButtonType="Button" CommandName="Edit" Text="Edit" />
</Columns>
<EditRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<RowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ORDCConnectionString1 %>"
DeleteCommand="DELETE FROM [Test_New_Transpick] WHERE [Brdcst_Nbr] = #original_Brdcst_Nbr AND (([Item_Nbr] = #original_Item_Nbr) OR ([Item_Nbr] IS NULL AND #original_Item_Nbr IS NULL)) AND [IsPicked] = #original_IsPicked AND (([Row] = #original_Row) OR ([Row] IS NULL AND #original_Row IS NULL))"
InsertCommand="INSERT INTO [Test_New_Transpick] ([Brdcst_Nbr], [Item_Nbr], [IsPicked], [Row]) VALUES (#Brdcst_Nbr, #Item_Nbr, #IsPicked, #Row)"
UpdateCommand="UPDATE [Test_New_Transpick] SET [IsPicked] = #IsPicked, [Row] = #Row WHERE [Brdcst_Nbr] = #original_Brdcst_Nbr"
OldValuesParameterFormatString="original_{0}"
ProviderName="<%$ ConnectionStrings:ORDCConnectionString1.ProviderName %>"
SelectCommand="SELECT * FROM [Test_New_Transpick]" >
<DeleteParameters>
<asp:Parameter Name="original_Brdcst_Nbr" Type="String" />
<asp:Parameter Name="original_Item_Nbr" Type="String" />
<asp:Parameter Name="original_IsPicked" Type="Boolean" />
<asp:Parameter Name="original_Row" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Brdcst_Nbr" Type="String" />
<asp:Parameter Name="Item_Nbr" Type="String" />
<asp:Parameter Name="IsPicked" Type="Boolean" />
<asp:Parameter Name="Row" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Item_Nbr" Type="String" />
<asp:Parameter Name="IsPicked" Type="Boolean" />
<asp:Parameter Name="Row" Type="String" />
<asp:Parameter Name="original_Brdcst_Nbr" Type="String" />
<asp:Parameter Name="original_Item_Nbr" Type="String" />
<asp:Parameter Name="original_IsPicked" Type="Boolean" />
<asp:Parameter Name="original_Row" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</center>
</body>
</html>
So, changing the property of the SQLdatabase from CompareAllValues to OverwriteChanges fixed this issue. It is now allowing the changes to be written back to the sql database by just changing the textbox in the row/column that needed to be updated without having to change anything else.