![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| 'Alo my repeater: Code: <asp:Repeater ID="rpProjectList" runat="server" OnItemDataBound="rpProjectList_OnItemDataBound">
<ItemTemplate>
<tr>
<td><asp:TextBox ID="txtName" Text='<%#Eval("Name")%>' runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="txtProjectNumber" Text='<%#Eval("ProjectNumber")%>' runat="server"></asp:TextBox></td>
<td><asp:TextBox ID="txtDecription" Text='<%#Eval("Description")%>' runat="server"></asp:TextBox></td>
<td><asp:Label ID="lblCreatedBy" runat="server" Text='<%#Eval("CreatedBy")%>'></asp:Label> <asp:Label ID="lblCreatedDate" runat="server" Text='<%#Eval("TheDate")%>'></asp:Label></td>
<td><asp:Label ID="lblEditedBy" runat="server" /> <asp:Label ID="lblEditedDate" runat="server" /></td>
<td><asp:Button ID="btnDelete" runat="server" Text="Delete" /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
so how does one go about pulling it off, and at the same time how do i pass it the idkey of the record I want to delete, cuz if i use a HiddenField, I get the same error, more than one, blah blah blah ![]() Shem |
| Sponsored Links |
|
#2
| ||||
| ||||
| In your repeater include OnItemCommand and on your button include CommandName and CommandArgument Code: <asp:Repeater ID="rpProjectList" runat="server" OnItemDataBound="rpProjectList_OnItemDataBound" OnItemCommand="rpProjectList_OnItemCommand" />
<asp:button id="btnDelete" runat="server" Text="Delete" CommandName="Delete" CommandArgument='<%#Eval("Idkey")%>' />
Code: sub rpProjectList_OnItemCommand(ByVal s As Object, ByVal e As RepeaterItemEventArgs) If e.CommandName="Delete" then 'Delete record with id e.CommandArgument End Sub |
| The Following User Says Thank You to richyrich For This Useful Post: | ||
Shem (July 11th, 2008) | ||
|
#3
| ||||
| ||||
| thanks a stack RR ![]() |
|
#4
| ||||
| ||||
| I had to change it to this to get rid of the errors: Code: Sub rpProjectList_OnItemCommand(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
Dim btnDelete As String = e.Item.FindControl("btnDelete").ToString
If btnDelete = "Delete" Then
Response.Write(btnDelete)
End If
End Sub
Code: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC31143: Method 'Public Sub rpProjectList_OnItemCommand(s As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs)' does not have a signature compatible with delegate 'Delegate Sub RepeaterCommandEventHandler(source As Object, e As System.Web.UI.WebControls.RepeaterCommandEventArgs)'. Source Error: Line 31: <td colspan="2">Edited By</td> Line 32: </tr> Line 33: <asp:Repeater ID="rpProjectList" runat="server" OnItemDataBound="rpProjectList_OnItemDataBound" OnItemCommand="rpProjectList_OnItemCommand" /> Line 34: <ItemTemplate> Line 35: <tr> Source File: C:\Inetpub\wwwroot\keithdesign\views\projects.aspx Line: 33 |
|
#5
| ||||
| ||||
| Shem, that's all wrong.. It should be like this: Code: Sub rpProjectList_OnItemCommand(ByVal s As Object, ByVal e As
RepeaterCommandEventArgs)
If e.CommandArgument = "delete" Then
'Do something...
End If
End Sub
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.Join our Folding team: DeveloperBarn Folding |
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
Shem (July 11th, 2008) | ||
|
#6
| ||||
| ||||
| Sorry, my bad....I hadn't realised you'd posted again...I thought it was working... Shem, J is correct...It should have been e As RepeaterCommandEventArgs But I then think it should be if e.CommandName="delete" then and the CommandArgument should be your Idkey. I'm sure that should work... |
| The Following User Says Thank You to richyrich For This Useful Post: | ||
Shem (July 11th, 2008) | ||
|
#7
| ||||
| ||||
| Yeap, RR is right. I wasn't paying attention to what I was doing. CommandName would tell us the action to perform and the CommandArgument tells us what record to peform it on. |
|
#8
| ||||
| ||||
| thanks guys |
|
#9
| ||||
| ||||
| Hi unfortunately nothing works, inside the IF statement I put a response.write and nothing writes to the screen ![]() any ideas on why? Shem |
|
#10
| ||||
| ||||
| Shem; Resposne.Write is probably not the best way to debug ASP.NET code. Can you set a breakpoint on the first statement in the event handler (you ARE using something like VWD or VS, right)? If you BP hits, you know the event handler is being fired, and you can example the e variable and ensure it has what you think it has. The code posted here (as corrected) should work. Also, post-up what you have now for a lookie.
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding ALL Button to Combo Box | Northernlion | Microsoft Access | 3 | July 8th, 2008 01:03 PM |
| adding numbers | todd2006 | JavaScript Programming | 2 | July 3rd, 2008 01:38 PM |