By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

RowDeleting event not handled .. deletecommand not enough?

P: n/a
Gridview with datasoure with deletecommand. Why do I need an event
handler? Isn't this enough?

I know this code has worked when I use a fielditemtemplate

<asp:GridView ID="RouteGridView" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="RouteId,DestId"
SkinID="GridView" Width="600px"
>
<EmptyDataTemplate>
No Data
</EmptyDataTemplate>
<Columns>
<asp:CommandField buttonType=Image ShowSelectButton="True"
SelectImageUrl="../App_Themes/WinXP_Silver/Images/edit.gif" />
<asp:CommandField ButtonType=Image ShowDeleteButton=true
DeleteImageUrl="../App_Themes/WinXP_Silver/Images/delete.gif" />
<asp:BoundField DataField="ProductCode" ItemStyle-Width="20"
HeaderText="Product Code"
SortExpression="Productcode" />
.... more here

In code behind, based on input I point it to this datasource:
<asp:SqlDataSource ID="RouteGridSourceAll" runat="server"
ConnectionString="<%$ ConnectionStrings:RTEConnectionString %>"
SelectCommand="SELECT Top 100
dbo.gen_getprodfromplan_fn(Planid) as productcode,* FROM
[GEN_RouteInfo_vw] WHERE startdate<=(case when @Dates='none' then
startdate else cast(@Dates as datetime) end) and enddate>=(case when
@Dates='None' then enddate else cast(@Dates as datetime) end) and
DestCode like (case when @Dest='None' then DestCode else '%'+@Dest+'%'
end) order by StartDate "
DeleteCommand="delete route where destid=@destId;delete
destination where destid=@destid">
<SelectParameters>
<asp:ControlParameter DefaultValue='none'
ControlID="DateFilter" Name="Dates" Type="String" />
<asp:ControlParameter DefaultValue='none'
ControlID="DestFilter" Name="Dest" Type="String" />
</SelectParameters>
<DeleteParameters>
<asp:ControlParameter DefaultValue=''
ControlID="RouteGridView" Name="Destid" Type="String" />
</DeleteParameters>
</asp:SqlDataSource>
</asp:Panel>

Nov 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.