aneilg
asked on
Cannot get my gridview to delete a row.
The problem is, it only works when i click on the edit button & it turns my bound fields into to editable textboxes.
The problem is I am already using the update button when I click on the edit button.
So currently my gridview displays EDIT button when I press this button my template field displays update - & Cancel. Is there anyway add the delete button to this as well.
The problem is I am already using the update button when I click on the edit button.
So currently my gridview displays EDIT button when I press this button my template field displays update - & Cancel. Is there anyway add the delete button to this as well.
<Columns>
<asp:CommandField showeditbutton="True" showdeletebutton="true" HeaderText="Add Remove Collegaue" ButtonType="Button" />
<asp:TemplateField HeaderText="ColleagueID" SortExpression="ColleagueID">
<EditItemTemplate>
<asp:TextBox ID="ColleagueID" runat="server" Text='<%# Bind("ColleagueID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblColleagueID" runat="server" Text='<%# Bind("ColleagueID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Colleague Name" SortExpression="ColleagueName">
<EditItemTemplate>
<asp:TextBox ID="ColleagueName" runat="server" Text='<%# Bind("ColleagueName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblColleagueName" runat="server" Text='<%# Bind("ColleagueName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mobile" SortExpression="Mobile">
<EditItemTemplate>
<asp:TextBox ID="Mobile" runat="server" Text='<%# Bind("Mobile") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblMobile" runat="server" Text='<%# Bind("Mobile") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Extension" SortExpression="Extension">
<EditItemTemplate>
<asp:TextBox ID="Extension" runat="server" Text='<%# Bind("Extension") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblExtension" runat="server" Text='<%# Bind("Extension") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:objectdatasource id="objdsColleagueDetails" runat="server" Typename="WAB_DataAccessWS.WAB_DataAccessWS" SelectMethod="selColleagueDetails"
UpdateMethod="updColleagueDetails" DeleteMethod="delColleagueDetails" InsertMethod="insColleaguedetails">
<selectparameters>
<asp:controlparameter ControlID="hdnMainConnStr" Name="strConn" Propertyname="Value" Type="String" />
<asp:ControlParameter ControlID="ddlDepartment" Name="intDepartmentID" PropertyName="SelectedValue" Type="Int32" />
</selectparameters>
<UpdateParameters>
<asp:controlparameter ControlID="hdnMainConnStr" Name="strConn" Propertyname="Value" Type="String" />
<asp:Parameter Name="ColleagueID" Type="Int32" />
<asp:Parameter Name="ColleagueName" Type="String" />
<asp:Parameter Name="Mobile" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
</UpdateParameters>
<DeleteParameters>
<asp:controlparameter ControlID="hdnMainConnStr" Name="strConn" Propertyname="Value" Type="String" />
<asp:Parameter Name="ColleagueID" Type="Int32" />
<asp:Parameter Name="ColleagueName" Type="String" />
<asp:Parameter Name="Mobile" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:controlparameter ControlID="hdnMainConnStr" Name="strConn" Propertyname="Value" Type="String" />
<asp:Parameter Name="ColleagueID" Type="Int32" />
<asp:Parameter Name="ColleagueName" Type="String" />
<asp:Parameter Name="Mobile" Type="String" />
<asp:Parameter Name="Extension" Type="String" />
</InsertParameters>
</asp:objectdatasource>
oops, amnualy = manually
ASKER
Thanks for that but i am using a webservice to call a sp that deletes the row.
the only problem i am having is it will not work unless my rows have been changed to textboxes as per my edit template fields.
the only problem i am having is it will not work unless my rows have been changed to textboxes as per my edit template fields.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for that.
Here a link that explait how to do it and a little more...
http://www.codeproject.com/KB/webforms/GridViewConfirmDelete.aspx