A
androoo
Hi
I am learing how to use the grid in asp.net.
Im trying to replace the button columns with nice friendly images.
So :
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
would become :
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton id="cmdDel" runat="server"
CommandName="Delete"
ImageUrl="pics/DELETE.JPG"
CausesValidation="false"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
but i just get a message saying Specified cast is not valid.
any ideas on what i may be doing .. here is the complete listing of my
grid code when its working without the template column for the delete
button:
<asp:datagrid id="dgReportCode" runat="server"
OnItemDataBound="dgReportCode_ItemDataBound" DataKeyField="ID"
OnDeleteCommand="dgReportCode_Delete"
OnUpdateCommand="dgReportCode_Update"
OnCancelCommand="dgReportCode_Cancel"
OnEditCommand="dgReportCode_Edit"
HeaderStyle-Font-Bold="True" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-ForeColor="Black" HeaderStyle-BackColor="Gold"
AutoGenerateColumns="False" CellPadding="2" ForeColor="Black">
<HeaderStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True"
HorizontalAlign="Center"
ForeColor="Gold"BackColor="Navy"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton id="ImageButton1" CommandName="Edit"
runat="server"
ImageUrl="pics/NOTEBOOK.JPG"></asp:ImageButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton id="Button4" runat="server"
Text="Update"
CommandName="Update" CausesValidation="false"></asp:LinkButton>
<asp:LinkButton id="Button3" runat="server"
Text="Cancel"
CommandName="Cancel" CausesValidation="false"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="ReportName" HeaderText="Report
Name"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Code">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
"Code") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=txtCode runat="server" Text='<%#
Container.DataItem("Code") %>' columns="70" TextMode="MultiLine"
Wrap="True" Rows="5"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Version"
HeaderText="Ver"></asp:BoundColumn>
</Columns>
</asp:datagrid>
I am learing how to use the grid in asp.net.
Im trying to replace the button columns with nice friendly images.
So :
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
would become :
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton id="cmdDel" runat="server"
CommandName="Delete"
ImageUrl="pics/DELETE.JPG"
CausesValidation="false"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
but i just get a message saying Specified cast is not valid.
any ideas on what i may be doing .. here is the complete listing of my
grid code when its working without the template column for the delete
button:
<asp:datagrid id="dgReportCode" runat="server"
OnItemDataBound="dgReportCode_ItemDataBound" DataKeyField="ID"
OnDeleteCommand="dgReportCode_Delete"
OnUpdateCommand="dgReportCode_Update"
OnCancelCommand="dgReportCode_Cancel"
OnEditCommand="dgReportCode_Edit"
HeaderStyle-Font-Bold="True" HeaderStyle-HorizontalAlign="Center"
HeaderStyle-ForeColor="Black" HeaderStyle-BackColor="Gold"
AutoGenerateColumns="False" CellPadding="2" ForeColor="Black">
<HeaderStyle Font-Size="8pt" Font-Names="Verdana" Font-Bold="True"
HorizontalAlign="Center"
ForeColor="Gold"BackColor="Navy"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Delete"
CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:ImageButton id="ImageButton1" CommandName="Edit"
runat="server"
ImageUrl="pics/NOTEBOOK.JPG"></asp:ImageButton>
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton id="Button4" runat="server"
Text="Update"
CommandName="Update" CausesValidation="false"></asp:LinkButton>
<asp:LinkButton id="Button3" runat="server"
Text="Cancel"
CommandName="Cancel" CausesValidation="false"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="ReportName" HeaderText="Report
Name"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Code">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,
"Code") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id=txtCode runat="server" Text='<%#
Container.DataItem("Code") %>' columns="70" TextMode="MultiLine"
Wrap="True" Rows="5"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="Version"
HeaderText="Ver"></asp:BoundColumn>
</Columns>
</asp:datagrid>