TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sathish kumar
NA
117
165.2k
gridview row deletion using 3 conditions in where statement in asp.net
Aug 19 2012 1:29 AM
hi friends...i want to delete particular row in gridview using three conditions in where statement .
Below is my source code. I used with DatakeyNames and deleted . But i want to give 2 more conditions . Based on those three conditions only i have to delete that particular row.
Below is mu source code.
Its urgent pls help me.....
<asp:GridView ID="gvPO" runat="server" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333"
GridLines="None" onrowcommand="gvPO_RowCommand" EmptyDataText="No Items Added"
onrowdatabound="gvPO_RowDataBound" DataSourceID="SqlPurchaseBill"
Width="907px" Height="167px" OnRowDeleting="gvPO_RowDeleting"
ShowFooter="True">
<FooterStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:ButtonField ButtonType="Link" Text="Select" CommandName="Select" />
<asp:TemplateField >
<ItemTemplate>
<asp:LinkButton ID="LinkButton1"
CommandName="Delete" runat="server" OnClientClick="javascript:return confirm('Do you really want to \ndelete the item?');">
Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ITEMDESCRIPTION" HeaderText="Description"
SortExpression="ITEMDESCRIPTION" />
<asp:BoundField DataField="BatchNo" HeaderText="BatchNo"
SortExpression="BatchNo" />
<asp:BoundField DataField="ExpiryDate" DataFormatString="{0:MM-yyyy}"
HeaderText="ExpiryDate" HtmlEncode="false" SortExpression="ExpiryDate" />
<asp:TemplateField HeaderText="Qty">
<ItemTemplate>
<asp:Label ID="lblQty" runat="server" Text='<%# Eval("QTY")%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalqty" runat="server" Text="0"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Free">
<ItemTemplate>
<asp:Label ID="lblFreeQty" runat="server" Text='<%# Eval("FreeQTY")%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalFreeqty" runat="server" Text="0"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="QtyPack">
<ItemTemplate>
<asp:Label ID="lblQtyPack" runat="server" Text='<%# Eval("PackQTY")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="StockQty">
<ItemTemplate>
<asp:Label ID="lblStockQty" runat="server" Text='<%# Eval("StockQTY")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TaxType" HeaderText="TaxType"
SortExpression="TaxType" />
<asp:TemplateField HeaderText="Rate">
<ItemTemplate>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("PURCHASERATE")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="MRP">
<ItemTemplate>
<asp:Label ID="lblMRP" runat="server" Text='<%# Eval("MRP")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TaxScheme" HeaderText="TaxScheme"
SortExpression="TaxScheme" />
<asp:TemplateField HeaderText="Item Rate">
<ItemTemplate>
<asp:Label ID="lblIRate" runat="server" Text='<%# Eval("ITEMRATE")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="MRP Rate">
<ItemTemplate>
<asp:Label ID="lblMRate" runat="server" Text='<%# Eval("MRPRATE")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DiscPer">
<ItemTemplate>
<asp:Label ID="lblDiscPer" runat="server" Text='<%# Eval("DiscPer")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DiscTotal">
<ItemTemplate>
<asp:Label ID="lblDiscTotal" runat="server" Text='<%# Eval("DiscTotal")%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblDiscountTotal" runat="server" Text="0.00"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VATOn" HeaderText="VATOn" SortExpression="VATOn" />
<asp:TemplateField HeaderText="Vat %">
<ItemTemplate>
<asp:Label ID="lblVATpercentage" runat="server"
Text='<%# Eval("VatPercentage")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="VatTotal">
<ItemTemplate>
<asp:Label ID="lblVTotal" runat="server" Text='<%# Eval("VatTotal")%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblVatTotal" runat="server" Text="0.00"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FreeVat Amt">
<ItemTemplate>
<asp:Label ID="lblFVat" runat="server" Text='<%# Eval("FreeVatAmt")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mrp Abate">
<ItemTemplate>
<asp:Label ID="lblMrpAbate" runat="server" Text='<%# Eval("MrpAbate")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TotalAmount">
<ItemTemplate>
<asp:Label ID="lblTAmount" runat="server" Text='<%# Eval("TotalAmount")%>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotalAmount" runat="server" Text="0.00"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VatOptions" HeaderText="VatOptions"
SortExpression="VatOptions" />
</Columns>
<PagerStyle CssClass="PagerStyle" />
<SelectedRowStyle CssClass="SelectedRowStyle" />
<HeaderStyle CssClass="HeaderStyle" />
<EditRowStyle CssClass="EditRowStyle" />
<AlternatingRowStyle CssClass="AltRowStyle" />
</asp:GridView>
<asp:SqlDataSource ID="SqlPurchaseBill" runat="server"
ConnectionString="<%$ ConnectionStrings:CMC %>"
SelectCommand="SELECT ITEMCODE,ITEMDESCRIPTION,BatchNo,ExpiryDate,QTY,PackQTY,FreeQTY,StockQTY,TaxType,PURCHASERATE,MRP,TaxScheme,ITEMRATE,MRPRATE,DiscPer,DiscTotal,VATOn,VatPercentage,VatTotal,FreeVatAmt,MrpAbate,TotalAmount,VatOptions from [Temp_PurchaseBill] ORDER BY [ITEMDESCRIPTION]"
DeleteCommand="DELETE FROM [Temp_PurchaseBill] WHERE BatchNo=@BatchNo "
>
</asp:SqlDataSource>
Above code is working . As i said earlier i want to give 3 conditions in that like below
DeleteCommand="DELETE FROM [Temp_PurchaseBill] WHERE BatchNo=@BatchNo " and ITEMDESCRIPTION=@ITEMDESCRIPTION" IPAddress=@IPAddress"
Its not working.....Help me pls
Reply
Answers (
9
)
asp.net panel control
custom validation control