|
-
Nov 4th, 2002, 02:11 PM
#1
Thread Starter
Frenzied Member
delete record from datagrid [RESOLVED]
I'm trying to delete a record from a datagrid, but can't seem to get my "Delete Command EventHandler" to fire. I have a datagrid with a delete button. Here's my code:
Sub deleteRecord(sender as Object, e as DataGridCommandEventArgs)
lblVerify.Text = "Record has been Deleted"
End Sub
<asp:datagrid id=DataGrid1 onDeleteCommand="deleteRecord" >
<asp:ButtonColumn CommandName="Delete">
when I click the delete button it never makes it to my "deleteRecord" procedure. Any suggestions?
thanks,
eye
Last edited by EyeTalion; Nov 5th, 2002 at 01:43 PM.
-
Nov 4th, 2002, 07:01 PM
#2
Hyperactive Member
I had a very similar problem a while ago. I actually gave and tried a different solution. Then I decided to try the datagrid command button solution again and this time it worked and I was certain I had exactly the same code the first time around but who knows 
The only thing that comes to mind in your case is you have no check in your code to see if it was the Delete command that was fired.
-
Nov 5th, 2002, 08:13 AM
#3
Thread Starter
Frenzied Member
it's not being fired. If it was I'd make it to my lblVerify.Text = "Record has been Deleted".
-
Nov 5th, 2002, 08:16 AM
#4
Thread Starter
Frenzied Member
here's the actual code:
Sub deleteRecord(sender as Object, e as DataGridCommandEventArgs)
lblVerify.Text = "Record has been Deleted"
End Sub
<asp:datagrid id=DataGrid1 onDeleteCommand="deleteRecord" style="Z-INDEX: 107; LEFT: 25px; POSITION: absolute; TOP: 203px" runat="server" Height="244px" Width="724px" Font-Names="Courier New" DataSource="<%# DataSet11 %>" DataMember="PBSS_BID" AutoGenerateColumns="False">
<AlternatingItemStyle ForeColor="Black" BackColor="Ivory"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="Black" BackColor="LightGray"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="BID_ID" SortExpression="BID_ID" HeaderText="BID ID"></asp:BoundColumn>
<asp:BoundColumn DataField="BID_TYPE_CODE" SortExpression="BID_TYPE_CODE" HeaderText="BID TYPE"></asp:BoundColumn>
<asp:BoundColumn DataField="BID_SCHEDULE_DESC" SortExpression="BID_SCHEDULE_DESC" HeaderText="DESCRPITION"></asp:BoundColumn>
<asp:BoundColumn DataField="BUYER_NAME" SortExpression="BUYER_NAME" HeaderText="BUYER"></asp:BoundColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton" HeaderText="DELETE" CommandName="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
-
Nov 5th, 2002, 01:31 PM
#5
Hyperactive Member
Try setting enableviewstate=false for the datagrid.
-
Nov 5th, 2002, 01:43 PM
#6
Thread Starter
Frenzied Member
musican you ROCK!! I've been banging my head for days now trying to figure this out....thanks, eye
what is the "EnableViewState" function?
-
Nov 5th, 2002, 01:48 PM
#7
Hyperactive Member
Enableviewstate saves the contents of the control to a hidden field in the generated form and is retained between posts so as to refill the control. When you post back a form with a textbox for example you should see what you typed into the textbox still there unless you set enableviewstate=false. It's important to set it to false for events to work properly in datagrids.
It's also important to set it to false when you know the control will be filled by a procedure because then it's uneccessary to save the data between pages and setting it to false reduces the amount of data in the hidden field and means the page will appear to the user quicker, especially if it's a datagrid with alot of items in it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|