DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   deleting values from the gridview (http://www.daniweb.com/forums/thread155663.html)

kapil.tandon Nov 6th, 2008 9:14 am
deleting values from the gridview
 
i have created the code like this
<asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" 
 onselectedindexchanged="grd_SelectedIndexChanged"        Width="100%">
  <Columns>
        <asp:BoundField DataField="ID" HeaderText="Budget ID" />

 <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
    </Columns>
  </asp:GridView>

a show delete field will appeat at run time.
i want to delete the row from the gridview.can anybody tell me how to do it?when i will click on the delete field at the execution time.

dickersonka Nov 7th, 2008 5:36 pm
Re: deleting values from the gridview
 
why not just delete the row from your datasource and reload the grid?

binoj_daniel Nov 11th, 2008 12:04 pm
Re: deleting values from the gridview
 
Quote:

Originally Posted by kapil.tandon (Post 729857)
i have created the code like this
<asp:GridView ID="grd" runat="server" AutoGenerateColumns="False" 
 onselectedindexchanged="grd_SelectedIndexChanged"        Width="100%">
  <Columns>
        <asp:BoundField DataField="ID" HeaderText="Budget ID" />

 <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
    </Columns>
  </asp:GridView>

a show delete field will appeat at run time.
i want to delete the row from the gridview.can anybody tell me how to do it?when i will click on the delete field at the execution time.

Do you only want to delete the row from the GridView and not from the DataBase?

sekharM Dec 3rd, 2009 6:11 am
HI...
It will work do like this.. ...

<Columns>
</asp:TemplateField>
<asp:CommandField
ButtonType = "Button"
ShowEditButton = "True" CausesValidation="false"
ShowDeleteButton = "True" HeaderText="Edit Controls"
/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDailyDatasource" runat="server"
ConnectionString="<%$ ConnectionStrings:ChdbConnectionString %>"
SelectCommand="Select * from Daily"
DeleteCommand="Delete from Daily where ItemsNo=@ItemsNo"
</asp:SqlDataSource>


All times are GMT -4. The time now is 5:55 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC