J
jobs
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>
</aspanel>
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>
</aspanel>