Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir I need help from someone that how data is deleted from the Sql through GridView. i tried my best but can't do this. plese give me some suitable example with codes.i will be grateful.
Posted

A gridview allows you to have a button on it to delete a row. The event for the click of that button would figure out the unique ID of the row, and delete it from the SQL and then refresh it's data source. Given that I know the web is full of examples, perhaps what you need to do is, first assure us that you're not being paid to write code when you are clearly not experienced enough to do basic research, then post your code and explain exactly where you are stuck.
 
Share this answer
 
on Aspx we do this code. and it need a Code Aspx.cs and we don't know that what code we can give on Cs page.please give me some tips about this.


<div>
<asp:GridView DataKeyNames="Catagory_Id" ID="GridView1" CssClass="Grid" Caption="All Catagories"
runat="server" Width="367px" AutoGenerateColumns="true"
OnPageIndexChanging="GridView1_PageIndexChanging"
EnableViewState="true" PageSize="2" PagerSettings-PageButtonCount="5"
AllowPaging="true" BorderStyle="Solid">
<columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnk1" runat="server" Text="Delete" OnClientClick="return cofirm('ARE YOU SURE TO DELETE?')" CommandName="Delete" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
<asp:SqlDataSource ID ="SqlDataSource1" runat="server" DeleteCommand= "Delete From Catagory Where Catagory_Id= @Catagory_Id">
<DeleteParameters>
<asp:Parameter Name="Catagory_Id" />
</DeleteParameters>
</asp:SqlDataSource>
<i>you are viewing page
<% =GridView1.PageIndex + 1%>
of
<%=GridView1.PageCount%>

</i>
</div>
 
Share this answer
 
Sir on Aspx we give this code. it need code on cs page onRowDeleting. what code we can give on ONRowDeleting in Cs page please give me some tips.


<div>
<asp:GridView DataKeyNames="Catagory_Id" ID="GridView1" CssClass="Grid" Caption="All Catagories"
runat="server" Width="367px" AutoGenerateColumns="true"
OnPageIndexChanging="GridView1_PageIndexChanging"
EnableViewState="true" PageSize="2" PagerSettings-PageButtonCount="5"
AllowPaging="true" BorderStyle="Solid">
<columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="lnk1" runat="server" Text="Delete" OnClientClick="return cofirm('ARE YOU SURE TO DELETE?')" CommandName="Delete" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
<asp:SqlDataSource ID ="SqlDataSource1" runat="server" DeleteCommand= "Delete From Catagory Where Catagory_Id= @Catagory_Id">
<DeleteParameters>
<asp:Parameter Name="Catagory_Id" />
</DeleteParameters>
</asp:SqlDataSource>
<i>you are viewing page
<% =GridView1.PageIndex + 1%>
of
<%=GridView1.PageCount%>

</i>
</div>
 
Share this answer
 
Have you done any research at all ? There's tons of examples on the web. You identify the column you want to delete by it's Id, then you call SQL to delete it.

Wow[^] - would you look at that !!!

plenty of examples there.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900