ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Deleting a row an item from a datagrid problems?? Posted by jbmarsh80 on 14 Nov 2002 at 5:53 PM
Hey everyone,

I am having a problem with a datagrid i set up. I can update the source just fine, but when i go to delete records, i get problems. As long as the primary Keys are in order and do not skip a number, it works fine, but when i add a record, delete it, then add another record, I can't delete the second record. The delete link shows as though it's been clicked before too. I don't know what's causing this problem. Here is the source i am using. Can anyone help??

sub asGrid_Delete(obj as object, e as DataGridCommandEventArgs)
dim strSQL as string = "DELETE FROM tbAvailableSituations _
WHERE asID = " & e.Item.ItemIndex + 1
ExecuteStatement(strSQL)
UpdateDate()
FillasDataGrid()
end sub

<asp:datagrid id="asGrid" runat="server" BorderColor="black" GridLines="Both" CellPadding="4" CellSpacing="0" width="450" ShowFooter="true" HeaderStyle-BackColor="#cccc99" FooterStyle-BackColor="#cccc99" ItemStyle-BackColor="#cccccc" AlternatingItemStyle-BackColor="#ffffff" AutoGenerateColumns="false" OnDeleteCommand="asGrid_Delete" onEditCommand="asGrid_Edit" onCancelCommand="asGrid_Cancel" OnUpdateCommand="asGrid_update" OnPageIndexChanged="asGrid_PageIndexChanged">
<columns>
<asp:templatecolumn headerText="ID">
<itemtemplate>
<asp:label id="ID" runat="server" text='<%# _
Container.Dataitem("asID") %>' />
</itemtemplate>
</asp:templatecolumn>

<asp:boundcolumn headertext="Situation" dataField="asSituation">
</asp:boundcolumn>

<asp:editcommandcolumn editText="edit" CancelText="Cancel"
UpdateText="Update" ItemStyle-Wrap="false"
HeaderText="Edit" />
<asp:buttoncolumn headertext=" " Text="Delete"
commandname="delete" />
</columns>
</asp:datagrid>

Report
Re: Deleting a row an item from a datagrid problems?? Posted by cvbiju on 6 Dec 2002 at 11:41 PM
: Hey everyone,
:
: I am having a problem with a datagrid i set up. I can update the source just fine, but when i go to delete records, i get problems. As long as the primary Keys are in order and do not skip a number, it works fine, but when i add a record, delete it, then add another record, I can't delete the second record. The delete link shows as though it's been clicked before too. I don't know what's causing this problem. Here is the source i am using. Can anyone help??
:
: sub asGrid_Delete(obj as object, e as DataGridCommandEventArgs)
: dim strSQL as string = "DELETE FROM tbAvailableSituations _
: WHERE asID = " & e.Item.ItemIndex + 1
: ExecuteStatement(strSQL)
: UpdateDate()
: FillasDataGrid()
: end sub
:
: <asp:datagrid id="asGrid" runat="server" BorderColor="black" GridLines="Both" CellPadding="4" CellSpacing="0" width="450" ShowFooter="true" HeaderStyle-BackColor="#cccc99" FooterStyle-BackColor="#cccc99" ItemStyle-BackColor="#cccccc" AlternatingItemStyle-BackColor="#ffffff" AutoGenerateColumns="false" OnDeleteCommand="asGrid_Delete" onEditCommand="asGrid_Edit" onCancelCommand="asGrid_Cancel" OnUpdateCommand="asGrid_update" OnPageIndexChanged="asGrid_PageIndexChanged">
: <columns>
: <asp:templatecolumn headerText="ID">
: <itemtemplate>
: <asp:label id="ID" runat="server" text='<%# _
: Container.Dataitem("asID") %>' />
: </itemtemplate>
: </asp:templatecolumn>
:
: <asp:boundcolumn headertext="Situation" dataField="asSituation">
: </asp:boundcolumn>
:
: <asp:editcommandcolumn editText="edit" CancelText="Cancel"
: UpdateText="Update" ItemStyle-Wrap="false"
: HeaderText="Edit" />
: <asp:buttoncolumn headertext=" " Text="Delete"
: commandname="delete" />
: </columns>
: </asp:datagrid>
:
:

c v Biju

Report
Re: Deleting a row an item from a datagrid problems?? Posted by cvbiju on 6 Dec 2002 at 11:47 PM
Visit this link,
http://www.aspnet.4guysfromrolla.com/articles/080702-1.2.aspx

look for the other parts.It is a multipart document(9 parts) and in one of the part..he has given the correct syntax to delete.


: : Hey everyone,
: :
: : I am having a problem with a datagrid i set up. I can update the source just fine, but when i go to delete records, i get problems. As long as the primary Keys are in order and do not skip a number, it works fine, but when i add a record, delete it, then add another record, I can't delete the second record. The delete link shows as though it's been clicked before too. I don't know what's causing this problem. Here is the source i am using. Can anyone help??
: :
: : sub asGrid_Delete(obj as object, e as DataGridCommandEventArgs)
: : dim strSQL as string = "DELETE FROM tbAvailableSituations _
: : WHERE asID = " & e.Item.ItemIndex + 1
: : ExecuteStatement(strSQL)
: : UpdateDate()
: : FillasDataGrid()
: : end sub
: :
: : <asp:datagrid id="asGrid" runat="server" BorderColor="black" GridLines="Both" CellPadding="4" CellSpacing="0" width="450" ShowFooter="true" HeaderStyle-BackColor="#cccc99" FooterStyle-BackColor="#cccc99" ItemStyle-BackColor="#cccccc" AlternatingItemStyle-BackColor="#ffffff" AutoGenerateColumns="false" OnDeleteCommand="asGrid_Delete" onEditCommand="asGrid_Edit" onCancelCommand="asGrid_Cancel" OnUpdateCommand="asGrid_update" OnPageIndexChanged="asGrid_PageIndexChanged">
: : <columns>
: : <asp:templatecolumn headerText="ID">
: : <itemtemplate>
: : <asp:label id="ID" runat="server" text='<%# _
: : Container.Dataitem("asID") %>' />
: : </itemtemplate>
: : </asp:templatecolumn>
: :
: : <asp:boundcolumn headertext="Situation" dataField="asSituation">
: : </asp:boundcolumn>
: :
: : <asp:editcommandcolumn editText="edit" CancelText="Cancel"
: : UpdateText="Update" ItemStyle-Wrap="false"
: : HeaderText="Edit" />
: : <asp:buttoncolumn headertext=" " Text="Delete"
: : commandname="delete" />
: : </columns>
: : </asp:datagrid>
: :
: :
:
: c v Biju
:
:

c v Biju




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.