When editing certain column values in my gridview, other values need to change depending on that value.
For example: http://i.imgur.com/phfVtUq.png
When editing the Truck Diesel column value, the KMPerLiter and RandsPerKM values must be changed according to that value and visa versa. The formulas are as follows:
KMPerLiter = TotaKM/TruckDiesel+TrailerDiesel and RandsPerKM = Amount/TotalKM.
This must be done within the edit column of the gridview.
All these values are then stored in a table in a database.
Here is the ASP.Net html source code:
UpdateCommand="UPDATE [Loads] SET [loadDate] = #loadDate, [loadDay] = #loadDay, [loadClient] = #loadClient, [loadDriver] = #loadDriver, [loadLoadingPoint1] = #loadLoadingPoint1, [loadLoadingPoint2] = #loadLoadingPoint2, [loadLoadingPoint3] = #loadLoadingPoint3, [loadOffloadingPoint1] = #loadOffloadingPoint1, [loadOffloadingPoint2] = #loadOffloadingPoint2, [loadOffloadingPoint3] = #loadOffloadingPoint3, [loadStops] = #loadStops, [loadNumber] = #loadNumber, [loadPodNumber] = #loadPodNumber, [loadAmount] = #loadAmount, [loadTruckReg] = #loadTruckReg, [loadTrailerReg] = #loadTrailerReg, [loadCategory] = #loadCategory, [loadDayOut] = #loadDayOut, [loadNightOut] = #loadNightOut, [loadOdoStart] = #loadOdoStart, [loadOdoEnd] = #loadOdoEnd, [loadTruckDiesel] = #loadTruckDiesel, [loadTrailerDiesel] = #loadTrailerDiesel, [loadInvoiceNumber] = #loadInvoiceNumber, [loadReceiptNumber] = #loadReceiptNumber, [loadKMperLiter] = #loadKMperLiter, [loadRandsPerKM] = #loadRandsPerKM, [loadDriverWage] = #loadDriverWage, [clientRecieved] = #clientRecieved, [loadTotalKM] = #loadTotalKM, [note] = #note WHERE [loadID] = #loadID">
<UpdateParameters>
<asp:Parameter DbType="Date" Name="loadDate" />
<asp:Parameter Name="loadDay" Type="String" />
<asp:Parameter Name="loadClient" Type="String" />
<asp:Parameter Name="loadDriver" Type="String" />
<asp:Parameter Name="loadLoadingPoint1" Type="String" />
<asp:Parameter Name="loadLoadingPoint2" Type="String" />
<asp:Parameter Name="loadLoadingPoint3" Type="String" />
<asp:Parameter Name="loadOffloadingPoint1" Type="String" />
<asp:Parameter Name="loadOffloadingPoint2" Type="String" />
<asp:Parameter Name="loadOffloadingPoint3" Type="String" />
<asp:Parameter Name="loadStops" Type="Int32" />
<asp:Parameter Name="loadNumber" Type="String" />
<asp:Parameter Name="loadPodNumber" Type="String" />
<asp:Parameter Name="loadAmount" Type="Decimal" />
<asp:Parameter Name="loadTruckReg" Type="String" />
<asp:Parameter Name="loadTrailerReg" Type="String" />
<asp:Parameter Name="loadCategory" Type="String" />
<asp:Parameter Name="loadDayOut" Type="Int32" />
<asp:Parameter Name="loadNightOut" Type="Int32" />
<asp:Parameter Name="loadOdoStart" Type="Int32" />
<asp:Parameter Name="loadOdoEnd" Type="Int32" />
<asp:Parameter Name="loadTruckDiesel" Type="Decimal" />
<asp:Parameter Name="loadTrailerDiesel" Type="Decimal" />
<asp:Parameter Name="loadInvoiceNumber" Type="String" />
<asp:Parameter Name="loadReceiptNumber" Type="String" />
<asp:Parameter Name="loadKMperLiter" Type="Decimal" />
<asp:Parameter Name="loadRandsPerKM" Type="Decimal" />
<asp:Parameter Name="loadDriverWage" Type="Int32" />
<asp:Parameter Name="clientRecieved" Type="String" />
<asp:Parameter Name="loadTotalKM" Type="Int32" />
<asp:Parameter Name="note" Type="String" />
<asp:Parameter Name="loadID" Type="Int32" />
</UpdateParameters>
Thanks in advance!
Method 1:
Creating Stored Procedure
Create Proc _SPUpdateTableName
#id int,
#truckvalue numeric(18,0)
as
begin
Update TableName set KMPerLiter = TotaKM/(#truckvalue+TrailerDiesel) , TruckDiesel = #truckvalue where ID =#id
end
On SqlDataSource code :
<asp:SqlDataSource ID="LocalServerDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" UpdateCommand="_SPUpdateTableName" UpdateCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="id" Type="Int32" />
<asp:Parameter Name="truckvalue " Type="Decimal" />
</UpdateParameters>
</asp:SqlDataSource>
Or Else in RowUpdate Method you can calculate the parameters and assign them to your UpdateCommand statement Parameter :
Method 2:
protected void grdvechile_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
decimal truckvalue= Convert.ToDecimal( grdvechile.Rows[e.RowIndex].Cells[1].Text);
// fetch all value as needed and typecast
decimal KMPerLiter = TotaKM/(truckvalue+TrailerDiesel);
//Pass your required parameter
LocalServerDataSource.UpdateParameters["truckvalue"].DefaultValue = truckvalue;
LocalServerDataSource.UpdateParameters["KMPerLiter "].DefaultValue = KMPerLiter ;
LocalServerDataSource.Update();
}
catch { }
}
Note: These code is only on logic I thought will be appicable for your situation not tested.Change as per your Requirment.
No need.. Only create a virtual table to pick up the Grid view value, Then change it according to your requirement, again reassign it to Grid view
Related
I'm reusing some code that I've had a lot of success with on other pages and the only significant difference here is that I'm capturing the value of a Checkbox in the filter panel that I haven't done in the past. Code sample is provided below, but the crux of what I'm running into is that I can't seem to find an acceptable set of parameters for the listed under the within the SqlDataSource.
What it throws is this: "The data types varchar and bit are incompatible in the add operator."
This is when I'm using Type="Boolean" in the asp:ControlParameter. I've tried numerious Types and other syntax within the asp:ControlParameter with no success.
<%--From the filter pannel--%>
<%--The SqlDataSource--%>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" CancelSelectOnNullParameter="false" ConnectionString='<%$ ConnectionStrings:csrConnectionString %>' DeleteCommand="DELETE FROM [csr_refdata_ip360_HostVulnerabilityCSV] WHERE [RecID] = #RecID" InsertCommand="INSERT INTO [csr_refdata_ip360_HostVulnerabilityCSV] ([DNS Name], [NetBIOS Name], [IP], [OS], [Vulnerability Score], [Vulnerability], [Vulnerability ID], [TicketNumber], [TicketClosed], [AssetID], [ExceptionID], [Notes]) VALUES (#DNS_Name, #NetBIOS_Name, #IP, #OS, #Vulnerability_Score, #Vulnerability, #Vulnerability_ID, #TicketNumber, #TicketClosed, #AssetID, #ExceptionID, #Notes)" SelectCommand="SELECT RecID, [DNS Name] AS DNS_Name, [NetBIOS Name] AS NetBIOS_Name, IP, OS, [Vulnerability Score] AS Vulnerability_Score, Vulnerability, [Vulnerability ID] AS Vulnerability_ID, TicketNumber, TicketClosed, AssetID, ExceptionID, Notes FROM csr_refdata_ip360_HostVulnerabilityCSV WHERE (Excepted = #Excepted) AND (RTRIM(LTRIM(ISNULL(#RecID, ''))) = '' OR RecID LIKE '%' + #RecID + '%') AND (RTRIM(LTRIM(ISNULL(#DNS_Name, ''))) = '' OR [DNS Name] LIKE '%' + #DNS_Name + '%') AND (RTRIM(LTRIM(ISNULL(#NetBIOS_Name, ''))) = '' OR [NetBIOS Name] LIKE '%' + #NetBIOS_Name + '%') AND (RTRIM(LTRIM(ISNULL(#IP, ''))) = '' OR IP LIKE '%' + #IP + '%') AND (RTRIM(LTRIM(ISNULL(#OS, ''))) = '' OR OS LIKE '%' + #OS + '%') AND (RTRIM(LTRIM(ISNULL(#Vulnerability_Score, ''))) = '' OR [Vulnerability Score] LIKE '%' + #Vulnerability_Score + '%') AND (RTRIM(LTRIM(ISNULL(#Vulnerability, ''))) = '' OR Vulnerability LIKE '%' + #Vulnerability + '%') AND (RTRIM(LTRIM(ISNULL(#Vulnerability_ID, ''))) = '' OR [Vulnerability ID] LIKE '%' + #Vulnerability_ID + '%') AND (RTRIM(LTRIM(ISNULL(#TicketNumber, ''))) = '' OR TicketNumber LIKE '%' + #TicketNumber + '%') AND (RTRIM(LTRIM(ISNULL(#TicketClosed, ''))) = '' OR TicketClosed LIKE '%' + #TicketClosed + '%') AND (RTRIM(LTRIM(ISNULL(#Notes, ''))) = '' OR Notes LIKE '%' + #Notes + '%') AND (RTRIM(LTRIM(ISNULL(#AssetID, ''))) = '' OR AssetID LIKE '%' + #AssetID + '%') AND (RTRIM(LTRIM(ISNULL(#ExceptionID, ''))) = '' OR ExceptionID LIKE '%' + #ExceptionID + '%') ORDER BY Vulnerability_Score DESC, Vulnerability, NetBIOS_Name" UpdateCommand="UPDATE [csr_refdata_ip360_HostVulnerabilityCSV] SET [DNS Name] = #DNS_Name, [NetBIOS Name] = #NetBIOS_Name, [IP] = #IP, [OS] = #OS, [Vulnerability Score] = #Vulnerability_Score, [Vulnerability] = #Vulnerability, [Vulnerability ID] = #Vulnerability_ID, [TicketNumber] = #TicketNumber, [TicketClosed] = #TicketClosed, [AssetID] = #AssetID, [ExceptionID] = #ExceptionID, [Notes] = #Notes WHERE [RecID] = #RecID">
<DeleteParameters>
<asp:Parameter Name="RecID" Type="Int32"></asp:Parameter>
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="DNS_Name" Type="String"></asp:Parameter>
<asp:Parameter Name="NetBIOS_Name" Type="String"></asp:Parameter>
<asp:Parameter Name="IP" Type="String"></asp:Parameter>
<asp:Parameter Name="OS" Type="String"></asp:Parameter>
<asp:Parameter Name="Vulnerability_Score" Type="Int16"></asp:Parameter>
<asp:Parameter Name="Vulnerability" Type="String"></asp:Parameter>
<asp:Parameter Name="Vulnerability_ID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="TicketNumber" Type="Int32"></asp:Parameter>
<asp:Parameter Name="TicketClosed" Type="Boolean"></asp:Parameter>
<asp:Parameter Name="AssetID" Type="Int64"></asp:Parameter>
<asp:Parameter Name="ExceptionID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="Notes" Type="String"></asp:Parameter>
</InsertParameters>
<SelectParameters>
<asp:Parameter DefaultValue="N" Name="Excepted" Type="String"></asp:Parameter>
<asp:ControlParameter Name="RecID" ControlID="RecID_Tbx" Type="Int32" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="DNS_Name" ControlID="DNSName_Tbx" Type="String" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="NetBIOS_Name" ControlID="NetBIOSName_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="IP" ControlID="IP_Tbx" Type="String" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="OS" ControlID="OS_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability_Score" ControlID="Vulnerability_Tbx" Type="Int16" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability" ControlID="Vulnerability_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability_ID" ControlID="VulnerabilityID_Tbx" Type="Int32" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="TicketNumber" ControlID="TicketNum_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<%--<%--<%-- This is the problem line below --%>--%>--%>
<asp:ControlParameter Name="TicketClosed" ControlID="TicketClosed_ChBox" Type="Boolean" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Notes" ControlID="Notes_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="AssetID" ControlID="AssetID_Tbx" Type="Int64" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="ExceptionID" ControlID="ExceptionID_Tbx" Type="String" ConvertEmptyStringToNull="true" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="DNS_Name" Type="String"></asp:Parameter>
<asp:Parameter Name="NetBIOS_Name" Type="String"></asp:Parameter>
<asp:Parameter Name="IP" Type="String"></asp:Parameter>
<asp:Parameter Name="OS" Type="String"></asp:Parameter>
<asp:Parameter Name="Vulnerability_Score" Type="Int16"></asp:Parameter>
<asp:Parameter Name="Vulnerability" Type="String"></asp:Parameter>
<asp:Parameter Name="Vulnerability_ID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="TicketNumber" Type="Int32"></asp:Parameter>
<asp:Parameter Name="TicketClosed" Type="Boolean"></asp:Parameter>
<asp:Parameter Name="AssetID" Type="Int64"></asp:Parameter>
<asp:Parameter Name="ExceptionID" Type="Int32"></asp:Parameter>
<asp:Parameter Name="Notes" Type="String"></asp:Parameter>
<asp:Parameter Name="RecID" Type="Int32"></asp:Parameter>
</UpdateParameters>
</asp:SqlDataSource>
Any insight on how I can stuff this checkbox into my ControlParameter properly would be greatly appreciated. I've pretty much exhausted my ideas.
I ended up altering the db table changing the column to varchar(1) so that I could set all BoundFields in the gridview. Then updated my to:
<SelectParameters>
<asp:Parameter DefaultValue="N" Name="Excepted" Type="String"></asp:Parameter>
<asp:ControlParameter Name="RecID" ControlID="RecID_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="DNS_Name" ControlID="DNSName_Tbx" Type="String" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="NetBIOS_Name" ControlID="NetBIOSName_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="IP" ControlID="IP_Tbx" Type="String" ConvertEmptyStringToNull="true"/>
<asp:ControlParameter Name="OS" ControlID="OS_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability_Score" ControlID="VulnerabilityScore_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability" ControlID="Vulnerability_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Vulnerability_ID" ControlID="VulnerabilityID_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="TicketNumber" ControlID="TicketNum_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="TicketClosed" ControlID="TicketClosed_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="Notes" ControlID="Notes_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="AssetID" ControlID="AssetID_Tbx" Type="String" ConvertEmptyStringToNull="true" />
<asp:ControlParameter Name="ExceptionID" ControlID="ExceptionID_Tbx" Type="String" ConvertEmptyStringToNull="true" />
Everything is working fine now....
MethodMan, thanks for your input! This one is done!
I have this code in my aspx file:
<asp:SqlDataSource ID="RegisterUserSQL" runat="server" ConnectionString="<%$ ConnectionStrings:UserQueries %>" ProviderName="<%$ ConnectionStrings:UserQueries.ProviderName %>"
InsertCommand="insert into users (firstname, lastname, username, password, email, gender, birthdate, nationality, currentcity)
values (:firstname, :lastname, :username, :password, :email, :gender, :date, :nationality, :currentcity)">
<InsertParameters>
<asp:Parameter Name="firstname" Type="String" />
<asp:Parameter Name="lastname" Type="String" />
<asp:Parameter Name="username" Type="String" />
<asp:Parameter Name="password" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="gender" Type="Char" />
<asp:Parameter Name="date" Type="String" />
<asp:Parameter Name="nationality" Type="String" />
<asp:Parameter Name="currentcity" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
Then this is the code behind:
RegisterUserSQL.InsertParameters["firstname"].DefaultValue = SavedFirstnameBox.Text;
RegisterUserSQL.InsertParameters["lastname"].DefaultValue = SavedLastnameBox.Text;
RegisterUserSQL.InsertParameters["username"].DefaultValue = SavedUsernameBox.Text;
RegisterUserSQL.InsertParameters["password"].DefaultValue = SavedPasswordBox.Text;
RegisterUserSQL.InsertParameters["email"].DefaultValue = SavedEmailBox.Text;
RegisterUserSQL.InsertParameters["gender"].DefaultValue = SavedGenderBox.Text;
RegisterUserSQL.InsertParameters["date"].DefaultValue = BirthdateBox.Text;
RegisterUserSQL.InsertParameters["nationality"].DefaultValue = SavedNationalityBox.Text;
RegisterUserSQL.InsertParameters["currentcity"].DefaultValue = SavedCurrentCityBox.Text;
RegisterUserSQL.Insert();
It stops at the last insert() statement and gives the error.
Any suggestions?
Im working using Gridview and Sqldatasource, so , when Im tried to use the updatecommand, but when I clicked on, nothing happen, so, if I save a new record and after click on update command button , so , it works well. do you have any idea about whats happening ?
the next is my code snipped
<asp:GridView ID="gvInfoCobradores" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateEditButton="True"
OnRowEditing="gvInfoAdmin_RowEditing" OnRowUpdating="gvInfoAdmin_RowUpdating"
DataSourceID="dsCobradorInfo" DataKeyNames="ID_Cobrador" Width="50%">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>
<asp:SqlDataSource ID="dsCobradorInfo" runat="server" ConnectionString="<%$ ConnectionStrings:SeminarioConnectionString %>"
SelectCommand="SELECT * FROM [UsuariosSistema].[Cobrador]"
OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [UsuariosSistema].[Cobrador] WHERE [ID_Cobrador] = #original_ID_Cobrador AND [NombreUsuarioCobrador] = #original_NombreUsuarioCobrador AND [PasswordCobrador] = #original_PasswordCobrador AND [NombreCobrador] = #original_NombreCobrador AND [ApellidoPaternoCobrador] = #original_ApellidoPaternoCobrador AND [ApellidoMaternoCobrador] = #original_ApellidoMaternoCobrador AND (([TelCobrador] = #original_TelCobrador) OR ([TelCobrador] IS NULL AND #original_TelCobrador IS NULL)) AND (([CelCobrador] = #original_CelCobrador) OR ([CelCobrador] IS NULL AND #original_CelCobrador IS NULL)) AND (([CorreElectronicoCobrador] = #original_CorreElectronicoCobrador) OR ([CorreElectronicoCobrador] IS NULL AND #original_CorreElectronicoCobrador IS NULL))"
InsertCommand="INSERT INTO [UsuariosSistema].[Cobrador] ([NombreUsuarioCobrador], [PasswordCobrador], [NombreCobrador], [ApellidoPaternoCobrador], [ApellidoMaternoCobrador], [TelCobrador], [CelCobrador], [CorreElectronicoCobrador]) VALUES (#NombreUsuarioCobrador, #PasswordCobrador, #NombreCobrador, #ApellidoPaternoCobrador, #ApellidoMaternoCobrador, #TelCobrador, #CelCobrador, #CorreElectronicoCobrador)"
UpdateCommand="UPDATE [UsuariosSistema].[Cobrador] SET [NombreUsuarioCobrador] = #NombreUsuarioCobrador, [PasswordCobrador] = #PasswordCobrador, [NombreCobrador] = #NombreCobrador, [ApellidoPaternoCobrador] = #ApellidoPaternoCobrador, [ApellidoMaternoCobrador] = #ApellidoMaternoCobrador, [TelCobrador] = #TelCobrador, [CelCobrador] = #CelCobrador, [CorreElectronicoCobrador] = #CorreElectronicoCobrador WHERE [ID_Cobrador] = #original_ID_Cobrador AND [NombreUsuarioCobrador] = #original_NombreUsuarioCobrador AND [PasswordCobrador] = #original_PasswordCobrador AND [NombreCobrador] = #original_NombreCobrador AND [ApellidoPaternoCobrador] = #original_ApellidoPaternoCobrador AND [ApellidoMaternoCobrador] = #original_ApellidoMaternoCobrador AND (([TelCobrador] = #original_TelCobrador) OR ([TelCobrador] IS NULL AND #original_TelCobrador IS NULL)) AND (([CelCobrador] = #original_CelCobrador) OR ([CelCobrador] IS NULL AND #original_CelCobrador IS NULL)) AND (([CorreElectronicoCobrador] = #original_CorreElectronicoCobrador) OR ([CorreElectronicoCobrador] IS NULL AND #original_CorreElectronicoCobrador IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_ID_Cobrador" Type="Int32" />
<asp:Parameter Name="original_NombreUsuarioCobrador" Type="String" />
<asp:Parameter Name="original_PasswordCobrador" Type="String" />
<asp:Parameter Name="original_NombreCobrador" Type="String" />
<asp:Parameter Name="original_ApellidoPaternoCobrador" Type="String" />
<asp:Parameter Name="original_ApellidoMaternoCobrador" Type="String" />
<asp:Parameter Name="original_TelCobrador" Type="String" />
<asp:Parameter Name="original_CelCobrador" Type="String" />
<asp:Parameter Name="original_CorreElectronicoCobrador" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="NombreUsuarioCobrador" Type="String" />
<asp:Parameter Name="PasswordCobrador" Type="String" />
<asp:Parameter Name="NombreCobrador" Type="String" />
<asp:Parameter Name="ApellidoPaternoCobrador" Type="String" />
<asp:Parameter Name="ApellidoMaternoCobrador" Type="String" />
<asp:Parameter Name="TelCobrador" Type="String" />
<asp:Parameter Name="CelCobrador" Type="String" />
<asp:Parameter Name="CorreElectronicoCobrador" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="NombreUsuarioCobrador" Type="String" />
<asp:Parameter Name="PasswordCobrador" Type="String" />
<asp:Parameter Name="NombreCobrador" Type="String" />
<asp:Parameter Name="ApellidoPaternoCobrador" Type="String" />
<asp:Parameter Name="ApellidoMaternoCobrador" Type="String" />
<asp:Parameter Name="TelCobrador" Type="String" />
<asp:Parameter Name="CelCobrador" Type="String" />
<asp:Parameter Name="CorreElectronicoCobrador" Type="String" />
<asp:Parameter Name="original_ID_Cobrador" Type="Int32" />
<asp:Parameter Name="original_NombreUsuarioCobrador" Type="String" />
<asp:Parameter Name="original_PasswordCobrador" Type="String" />
<asp:Parameter Name="original_NombreCobrador" Type="String" />
<asp:Parameter Name="original_ApellidoPaternoCobrador" Type="String" />
<asp:Parameter Name="original_ApellidoMaternoCobrador" Type="String" />
<asp:Parameter Name="original_TelCobrador" Type="String" />
<asp:Parameter Name="original_CelCobrador" Type="String" />
<asp:Parameter Name="original_CorreElectronicoCobrador" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks in advance!!
I tried using date/time, time, but it doesn't help.
Exception Details: System.Web.HttpException: DataBinding: 'DatePickerControl.DatePicker' does not contain a property with the name 'Text'.
Source Error:
Line 31: DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
Line 32:
Line 33: DataSource.Insert();//here is the error
Line 34:
Line 35: }
Here is the html code :
<asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
InsertCommand="INSERT INTO [UserDetails] ([UserId], [CustName], [CustNum], [CustRole], [CustStatus], [PName], [PEmail], [PRole], [WedDate]) VALUES (#UserId, #CustName, #CustNum, #CustRole, #CustStatus, #PName, #PEmail, #PRole, #WedDate)"
ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString1.ProviderName %>">
<InsertParameters>
<asp:ControlParameter Name="CustName" Type="String" ControlID="CustName" PropertyName="Text" />
<asp:ControlParameter Name="CustNum" Type="String" ControlID="CustNum" PropertyName="Text" />
<asp:ControlParameter Name="CustRole" Type="String" ControlID="CustRole" PropertyName="Text" />
<asp:ControlParameter Name="CustStatus" Type="String" ControlID="CustStatus" PropertyName="Text" />
<asp:ControlParameter Name="PName" Type="String" ControlID="PName" PropertyName="Text" />
<asp:ControlParameter Name="PEmail" Type="String" ControlID="PEmail" PropertyName="Text" />
<asp:ControlParameter Name="PRole" Type="String" ControlID="PRole" PropertyName="Text" />
<asp:ControlParameter Name="WedDate" Type="String" ControlID="WedDate" PropertyName="Text"/>
</InsertParameters>
</asp:SqlDataSource>
Set PropertyName="SelectedValue" and Type="DateTime"
<asp:ControlParameter Name="WedDate" Type="DateTime" ControlID="WedDate" PropertyName="SelectedValue"/>
EDIT:
try
<asp:ControlParameter Name="WedDate" Type="DateTime" ControlID="WedDate" PropertyName="SelectedDate"/>
Change
Type="String" to Type="DateTime" and
PropertyName="Text" to PropertyName="SelectedDate"
on this line
<asp:ControlParameter Name="WedDate" Type="DateTime" ControlID="WedDate" PropertyName="SelectedDate" />
i have a webform with a gridview. i have the UPDATE button next to each row. however when i press the button and edit the field and press UPDATE. it does not change anything. here's the code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" CellPadding="4"
DataKeyNames="lom_number" DataSourceID="SqlDataSource1" ForeColor="#333333"
GridLines="None" onselectedindexchanged="GridView1_SelectedIndexChanged">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="occurrence_date" HeaderText="occurrence_date"
SortExpression="occurrence_date" />
<asp:BoundField DataField="report_date" HeaderText="report_date"
SortExpression="report_date" />
<asp:BoundField DataField="report_by" HeaderText="report_by"
SortExpression="report_by" />
<asp:BoundField DataField="identified_by" HeaderText="identified_by"
SortExpression="identified_by" />
<asp:BoundField DataField="section_c_issue_error_identified_by"
HeaderText="section_c_issue_error_identified_by"
SortExpression="section_c_issue_error_identified_by" />
<asp:BoundField DataField="section_c_comments" HeaderText="section_c_comments"
SortExpression="section_c_comments" />
<asp:BoundField DataField="section_d_investigation"
HeaderText="section_d_investigation" SortExpression="section_d_investigation" />
<asp:BoundField DataField="section_e_corrective_action"
HeaderText="section_e_corrective_action"
SortExpression="section_e_corrective_action" />
<asp:BoundField DataField="section_f_comments" HeaderText="section_f_comments"
SortExpression="section_f_comments" />
<asp:BoundField DataField="pre_practice_code" HeaderText="pre_practice_code"
SortExpression="pre_practice_code" />
<asp:BoundField DataField="pre_contact" HeaderText="pre_contact"
SortExpression="pre_contact" />
<asp:BoundField DataField="lom_number" HeaderText="lom_number"
InsertVisible="False" ReadOnly="True" SortExpression="lom_number" />
<asp:BoundField DataField="windows_user" HeaderText="windows_user"
SortExpression="windows_user" />
<asp:BoundField DataField="computer_name" HeaderText="computer_name"
SortExpression="computer_name" />
<asp:BoundField DataField="time_stamp" HeaderText="time_stamp"
SortExpression="time_stamp" />
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:LOM %>"
SelectCommand="SELECT * FROM [Main_LOM_Form]"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [Main_LOM_Form] WHERE [lom_number] = #original_lom_number AND (([occurrence_date] = #original_occurrence_date) OR ([occurrence_date] IS NULL AND #original_occurrence_date IS NULL)) AND (([report_date] = #original_report_date) OR ([report_date] IS NULL AND #original_report_date IS NULL)) AND (([report_by] = #original_report_by) OR ([report_by] IS NULL AND #original_report_by IS NULL)) AND (([identified_by] = #original_identified_by) OR ([identified_by] IS NULL AND #original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = #original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND #original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = #original_section_c_comments) OR ([section_c_comments] IS NULL AND #original_section_c_comments IS NULL)) AND (([section_d_investigation] = #original_section_d_investigation) OR ([section_d_investigation] IS NULL AND #original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = #original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND #original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = #original_section_f_comments) OR ([section_f_comments] IS NULL AND #original_section_f_comments IS NULL)) AND (([pre_practice_code] = #original_pre_practice_code) OR ([pre_practice_code] IS NULL AND #original_pre_practice_code IS NULL)) AND (([pre_contact] = #original_pre_contact) OR ([pre_contact] IS NULL AND #original_pre_contact IS NULL)) AND [windows_user] = #original_windows_user AND [computer_name] = #original_computer_name AND [time_stamp] = #original_time_stamp"
InsertCommand="INSERT INTO [Main_LOM_Form] ([occurrence_date], [report_date], [report_by], [identified_by], [section_c_issue_error_identified_by], [section_c_comments], [section_d_investigation], [section_e_corrective_action], [section_f_comments], [pre_practice_code], [pre_contact], [windows_user], [computer_name], [time_stamp]) VALUES (#occurrence_date, #report_date, #report_by, #identified_by, #section_c_issue_error_identified_by, #section_c_comments, #section_d_investigation, #section_e_corrective_action, #section_f_comments, #pre_practice_code, #pre_contact, #windows_user, #computer_name, #time_stamp)"
OldValuesParameterFormatString="original_{0}"
UpdateCommand="UPDATE [Main_LOM_Form] SET [occurrence_date] = #occurrence_date, [report_date] = #report_date, [report_by] = #report_by, [identified_by] = #identified_by, [section_c_issue_error_identified_by] = #section_c_issue_error_identified_by, [section_c_comments] = #section_c_comments, [section_d_investigation] = #section_d_investigation, [section_e_corrective_action] = #section_e_corrective_action, [section_f_comments] = #section_f_comments, [pre_practice_code] = #pre_practice_code, [pre_contact] = #pre_contact, [windows_user] = #windows_user, [computer_name] = #computer_name, [time_stamp] = #time_stamp WHERE [lom_number] = #original_lom_number AND (([occurrence_date] = #original_occurrence_date) OR ([occurrence_date] IS NULL AND #original_occurrence_date IS NULL)) AND (([report_date] = #original_report_date) OR ([report_date] IS NULL AND #original_report_date IS NULL)) AND (([report_by] = #original_report_by) OR ([report_by] IS NULL AND #original_report_by IS NULL)) AND (([identified_by] = #original_identified_by) OR ([identified_by] IS NULL AND #original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = #original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND #original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = #original_section_c_comments) OR ([section_c_comments] IS NULL AND #original_section_c_comments IS NULL)) AND (([section_d_investigation] = #original_section_d_investigation) OR ([section_d_investigation] IS NULL AND #original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = #original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND #original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = #original_section_f_comments) OR ([section_f_comments] IS NULL AND #original_section_f_comments IS NULL)) AND (([pre_practice_code] = #original_pre_practice_code) OR ([pre_practice_code] IS NULL AND #original_pre_practice_code IS NULL)) AND (([pre_contact] = #original_pre_contact) OR ([pre_contact] IS NULL AND #original_pre_contact IS NULL)) AND [windows_user] = #original_windows_user AND [computer_name] = #original_computer_name AND [time_stamp] = #original_time_stamp">
<DeleteParameters>
<asp:Parameter Name="original_lom_number" Type="Int32" />
<asp:Parameter DbType="Date" Name="original_occurrence_date" />
<asp:Parameter DbType="Date" Name="original_report_date" />
<asp:Parameter Name="original_report_by" Type="String" />
<asp:Parameter Name="original_identified_by" Type="String" />
<asp:Parameter Name="original_section_c_issue_error_identified_by"
Type="String" />
<asp:Parameter Name="original_section_c_comments" Type="String" />
<asp:Parameter Name="original_section_d_investigation" Type="String" />
<asp:Parameter Name="original_section_e_corrective_action" Type="String" />
<asp:Parameter Name="original_section_f_comments" Type="String" />
<asp:Parameter Name="original_pre_practice_code" Type="String" />
<asp:Parameter Name="original_pre_contact" Type="String" />
<asp:Parameter Name="original_windows_user" Type="String" />
<asp:Parameter Name="original_computer_name" Type="String" />
<asp:Parameter Name="original_time_stamp" Type="DateTime" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter DbType="Date" Name="occurrence_date" />
<asp:Parameter DbType="Date" Name="report_date" />
<asp:Parameter Name="report_by" Type="String" />
<asp:Parameter Name="identified_by" Type="String" />
<asp:Parameter Name="section_c_issue_error_identified_by" Type="String" />
<asp:Parameter Name="section_c_comments" Type="String" />
<asp:Parameter Name="section_d_investigation" Type="String" />
<asp:Parameter Name="section_e_corrective_action" Type="String" />
<asp:Parameter Name="section_f_comments" Type="String" />
<asp:Parameter Name="pre_practice_code" Type="String" />
<asp:Parameter Name="pre_contact" Type="String" />
<asp:Parameter Name="windows_user" Type="String" />
<asp:Parameter Name="computer_name" Type="String" />
<asp:Parameter Name="time_stamp" Type="DateTime" />
<asp:Parameter Name="original_lom_number" Type="Int32" />
<asp:Parameter DbType="Date" Name="original_occurrence_date" />
<asp:Parameter DbType="Date" Name="original_report_date" />
<asp:Parameter Name="original_report_by" Type="String" />
<asp:Parameter Name="original_identified_by" Type="String" />
<asp:Parameter Name="original_section_c_issue_error_identified_by"
Type="String" />
<asp:Parameter Name="original_section_c_comments" Type="String" />
<asp:Parameter Name="original_section_d_investigation" Type="String" />
<asp:Parameter Name="original_section_e_corrective_action" Type="String" />
<asp:Parameter Name="original_section_f_comments" Type="String" />
<asp:Parameter Name="original_pre_practice_code" Type="String" />
<asp:Parameter Name="original_pre_contact" Type="String" />
<asp:Parameter Name="original_windows_user" Type="String" />
<asp:Parameter Name="original_computer_name" Type="String" />
<asp:Parameter Name="original_time_stamp" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter DbType="Date" Name="occurrence_date" />
<asp:Parameter DbType="Date" Name="report_date" />
<asp:Parameter Name="report_by" Type="String" />
<asp:Parameter Name="identified_by" Type="String" />
<asp:Parameter Name="section_c_issue_error_identified_by" Type="String" />
<asp:Parameter Name="section_c_comments" Type="String" />
<asp:Parameter Name="section_d_investigation" Type="String" />
<asp:Parameter Name="section_e_corrective_action" Type="String" />
<asp:Parameter Name="section_f_comments" Type="String" />
<asp:Parameter Name="pre_practice_code" Type="String" />
<asp:Parameter Name="pre_contact" Type="String" />
<asp:Parameter Name="windows_user" Type="String" />
<asp:Parameter Name="computer_name" Type="String" />
<asp:Parameter Name="time_stamp" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>
here is the query that it i intercepted with james' help:
updateQuery "UPDATE [Main_LOM_Form] SET [occurrence_date] = #occurrence_date, [report_date] = #report_date, [report_by] = #report_by, [identified_by] = #identified_by, [section_c_issue_error_identified_by] = #section_c_issue_error_identified_by, [section_c_comments] = #section_c_comments, [section_d_investigation] = #section_d_investigation, [section_e_corrective_action] = #section_e_corrective_action, [section_f_comments] = #section_f_comments, [pre_practice_code] = #pre_practice_code, [pre_contact] = #pre_contact, [windows_user] = #windows_user, [computer_name] = #computer_name, [time_stamp] = #time_stamp WHERE [lom_number] = #original_lom_number AND (([occurrence_date] = #original_occurrence_date) OR ([occurrence_date] IS NULL AND #original_occurrence_date IS NULL)) AND (([report_date] = #original_report_date) OR ([report_date] IS NULL AND #original_report_date IS NULL)) AND (([report_by] = #original_report_by) OR ([report_by] IS NULL AND #original_report_by IS NULL)) AND (([identified_by] = #original_identified_by) OR ([identified_by] IS NULL AND #original_identified_by IS NULL)) AND (([section_c_issue_error_identified_by] = #original_section_c_issue_error_identified_by) OR ([section_c_issue_error_identified_by] IS NULL AND #original_section_c_issue_error_identified_by IS NULL)) AND (([section_c_comments] = #original_section_c_comments) OR ([section_c_comments] IS NULL AND #original_section_c_comments IS NULL)) AND (([section_d_investigation] = #original_section_d_investigation) OR ([section_d_investigation] IS NULL AND #original_section_d_investigation IS NULL)) AND (([section_e_corrective_action] = #original_section_e_corrective_action) OR ([section_e_corrective_action] IS NULL AND #original_section_e_corrective_action IS NULL)) AND (([section_f_comments] = #original_section_f_comments) OR ([section_f_comments] IS NULL AND #original_section_f_comments IS NULL)) AND (([pre_practice_code] = #original_pre_practice_code) OR ([pre_practice_code] IS NULL AND #original_pre_practice_code IS NULL)) AND (([pre_contact] = #original_pre_contact) OR ([pre_contact] IS NULL AND #original_pre_contact IS NULL)) AND [windows_user] = #original_windows_user AND [computer_name] = #original_computer_name AND [time_stamp] = #original_time_stamp" string
what am i doing wrong?
I would suggest adding an OnUpdating event handler so you can look at the CommandText before the query is executed. That should help you identify if there's an issue with the query.
In the markup:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" OnUpdating="SqlDataSource1_Updating" ... >
In the code-behind:
protected void SqlDataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
string updateQuery = e.Command.CommandText;
//inspect the update query
}