Hello All,
I am developing modules to extend the functioanlity of my DNN application.
I am using a GridView and am not able to get the Delete functionality working fine.
I have got Edit to work fine but Delete Does not.
I am trying to raise the RowCommand method of the GridView but it does not work well with DNN.
Any known issues or is it just that I am doing something wrong here. Please suggest.
Here is what the Grid looks like.
<asp:GridView ID="grdVaccineChart" runat="server" GridLines="None" AutoGenerateColumns="false"
Visible="true" EnableViewState="False" CssClass="dnnGrid"
OnRowDataBound="OnVaccineChartRowDataBound"
OnRowCommand="OnVaccineChartRowCommand">
<HeaderStyle CssClass="dnnGridHeader" VerticalAlign="Top" />
<RowStyle CssClass="dnnGridItem" HorizontalAlign="Left" />
<AlternatingRowStyle CssClass="dnnGridAltItem" />
<FooterStyle CssClass="dnnGridFooter" />
<PagerStyle CssClass="dnnGridPager" />
<Columns>
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:HyperLink ID="editButton" Text="Edit" runat="server" CssClass="SkinObject" />
<asp:LinkButton ID="deleteButton" runat="server" CssClass="SkinObject" CommandName="DeleteVaccine" CausesValidation="false"
Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this user?');" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VaccineName" HeaderText="Vaccine" ItemStyle-HorizontalAlign="Center"
SortExpression="VaccineName" ItemStyle-Width="14%">
<ItemStyle HorizontalAlign="Center" Width="14%"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Period" HeaderText="Vaccine Period" ItemStyle-HorizontalAlign="Center"
SortExpression="Period" ItemStyle-Width="14%">
<ItemStyle HorizontalAlign="Center" Width="14%"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Duration" HeaderText="Vaccine Duration" ItemStyle-HorizontalAlign="Center"
SortExpression="Duration" ItemStyle-Width="14%">
<ItemStyle HorizontalAlign="Center" Width="14%"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Period2" HeaderText="Vaccine Period 2" ItemStyle-HorizontalAlign="Center"
SortExpression="Period2" ItemStyle-Width="14%">
<ItemStyle HorizontalAlign="Center" Width="14%"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="Duration2" HeaderText="Vaccine Duration 2" ItemStyle-HorizontalAlign="Center"
SortExpression="Duration2" ItemStyle-Width="14%">
<ItemStyle HorizontalAlign="Center" Width="14%"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="VaccinePurpose" HeaderText="Purpose" SortExpression="VaccinePurpose"
ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
<EmptyDataTemplate>
<div class="dnnFormMessage dnnFormWarning">
<%= NoVaccineChart %></div>
</EmptyDataTemplate>
</asp:GridView>
And the code behind looks like below:
protected void OnVaccineChartRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DeleteVaccine")
{
Int32 vaccineId = Convert.ToInt32(e.CommandArgument);
AddEditVaccineController objAddEditVaccines = new AddEditVaccineController();
objAddEditVaccines.DeleteAddEditVaccine(vaccineId);
}
}
Thanks a lot ..
Ashutosh