Hi,
I have a GridView that has 10 fields, 6 are normal, 7th is a CheckBox, 8th, 9th, 10th are buttons.
7th - CheckBox is a tempate Field. The rest are normal.
<asp:GridView ID="GridView2" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="UserName,ID" onrowcommand="GridView2_RowCommand" Width="1053px" style="text-align: center" onrowdatabound="GridView2_RowDataBound"><Columns><asp:BoundField DataField="ID" HeaderText="ID" /><asp:BoundField DataField="RequestedDate" HeaderText="RequestedDate" /><asp:BoundField DataField="DeanDirectorName" HeaderText="DeanDirector" /><asp:BoundField DataField="UserName" HeaderText="UserName" /><asp:BoundField DataField="PhoneExt" HeaderText="PhoneExt" /><asp:BoundField DataField="RoomNo" HeaderText="RoomNo" /><asp:TemplateField HeaderText="Approve"><ItemTemplate><asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Approve") %>' /></ItemTemplate><EditItemTemplate><asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("Approve") %>' /></EditItemTemplate></asp:TemplateField><asp:ButtonField CommandName="View" HeaderText="View" Text="View" /><asp:ButtonField CommandName="Approve" HeaderText="Approve" Text="Approve" /><asp:TemplateField HeaderText="Decline" ShowHeader="False"><ItemTemplate><asp:Button ID="btnDecline" runat="server" CausesValidation="false" OnClick = "btnDecline_Click" CommandName="Decline" Text="Decline" /></ItemTemplate></asp:TemplateField></Columns></asp:GridView>
Now when I open the Form with GridView, it opens up well. But when I click on the Decline Button,. the whole GridView gets lost.
It does give me an error. It says: "Specified cast is not valid"
It gives at this location:
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Approve") %>'
Any ideas?
some error occurs here, and so the GridView doesnt load and exits.