ChibibrePew
New Member
I am facing problem when i am inserting and update multiple record when i click on svae button. when i click on save button first time it should insert bid percentage or bid amt record and second time update record using storeprocedure in sqldatasource \[code\] <asp:Button runat="server" ID="SaveButton" Text="Save Data" /> <rwg:BulkEditGridView ID="EditableGrid" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="Pk_PropertyID" SaveButtonID="SaveButton" runat="server"> <Columns> <asp:BoundField HeaderText="Pk_PropertyID" DataField="Pk_PropertyID" ReadOnly="true" InsertVisible="False" SortExpression="Pk_PropertyID" /> <asp:BoundField HeaderText="FK_ActionTaken" DataField="FK_ActionTaken" SortExpression="FK_ActionTaken" ReadOnly="true" /> <asp:BoundField HeaderText="ParcelNumber" DataField="ParcelNumber" SortExpression="ParcelNumber" ReadOnly="true" /> <asp:BoundField HeaderText="OwnerName" DataField="OwnerName" SortExpression="OwnerName" ReadOnly="true" /> <asp:BoundField HeaderText="PropertyAddress" DataField="PropertyAddress" SortExpression="PropertyAddress" ReadOnly="true" /> <asp:BoundField HeaderText="AssessedValue" DataField="AssessedValue" SortExpression="AssessedValue" ReadOnly="true" /> <asp:BoundField HeaderText="SaleAmout" DataField="SaleAmout" SortExpression="SaleAmout" ReadOnly="true" /> <asp:BoundField HeaderText="HighBidPrimium" DataField="HighBidPrimium" SortExpression="HighBidPrimium" ReadOnly="true" /> <asp:BoundField HeaderText="BidPercentage" DataField="BidPercentage" SortExpression="BidPercentage" /> <asp:BoundField DataField="BidDollarAmt" HeaderText="BidDollarAmt" SortExpression="BidDollarAmt" /> <asp:BoundField DataField="HBP" HeaderText="HBP" SortExpression="HBP" ReadOnly="true" /> <asp:BoundField DataField="AmtDue" HeaderText="AmtDue" SortExpression="AmtDue" ReadOnly="true" /> <asp:BoundField DataField="FK_BSID" HeaderText="FK_BSID" SortExpression="FK_BSID" ReadOnly="true" /> </Columns> </rwg:BulkEditGridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStringsBMain01ConnectionString %>" SelectCommand="Proplist" SelectCommandType="StoredProcedure" UpdateCommand="propbid" UpdateCommandType="StoredProcedure"> <SelectParameters> <asparameter DefaultValue="http://stackoverflow.com/questions/15606861/8" Name="bidderid" Type="Int32" /> </SelectParameters> <UpdateParameters> <asparameter Name="FK_BidderId" Type="Int32" DefaultValue="http://stackoverflow.com/questions/15606861/8" /> <asparameter Name="FK_PropertyId" Type="Int32" /> <asparameter Name="FK_ActionTaken" Type="Int32" /> <asparameter Name="BidDateTime" Type="DateTime" /> <asparameter Name="BidPercentage" Type="Double" /> <asparameter Name="BidDollarAmt" Type="Double" /> <asparameter Name="HBP" Type="Double" /> <asparameter Name="AmtDue" Type="Double" /> </UpdateParameters> </asp:SqlDataSource> > here is store procedure for insert and updATE\[/code\]\[code\]enter code here\[/code\] ALTER PROCEDURE [dbo].[propbid] @FK_BidderId int, @FK_PropertyId int, @FK_ActionTaken int, @BidDateTime datetime, @BidPercentage float, @BidDollarAmt float, @HBP float, @AmtDue float AS BEGIN\[code\] IF EXISTS (select * from tblPlanBid WHERE (FK_BidderID = @FK_BidderId) AND (FK_PropertyID = @FK_PropertyId)) BEGIN UPDATE tblPlanBid SET BidDateTime =@BidDateTime,FK_ActionTaken = 1, BidPercentage = @BidPercentage, BidDollarAmt = @BidDollarAmt,HBP=@HBP, AmtDue=@AmtDue WHERE ( FK_BidderID = @FK_BidderId) AND ( FK_PropertyID = @FK_PropertyId) END ELSE BEGIN INSERT INTO [tblPlanBid] ([FK_BidderID] ,[FK_PropertyID] ,[FK_ActionTaken] ,[BidDateTime] ,[BidPercentage] ,[BidDollarAmt] ,[HBP] ,[AmtDue]) VALUES(@FK_BidderId,@FK_PropertyId,@FK_ActionTaken,@BidDateTime,@BidPercentage,@BidDollarAmt,@HBP,@AmtDue) ENDEND\[/code\]