Link to home
Start Free TrialLog in
Avatar of sabev
sabev

asked on

Data binding won't update source.

I have a checkbox in a template field in a gridview.  Two way binding is set for the checkbox control.  But, checking the checkbox does not update the source table.

(Line 26 in the code is the actual bind)

What might I be missing?  Thanks.
<asp:GridView ID="GridViewBrowse" runat="server" AllowSorting="True" 
                        BackColor="White" BorderColor="White" BorderStyle="Ridge"
                        BorderWidth="2px" CellPadding="3" CellSpacing="1" CssClass="TableFont" DataSourceID="SqlDataSourceBrowse"
                        EmptyDataText="Records will be displayed here.  Click select on a record for detailed data"
                        GridLines="None" Height="1px" PageSize="6" TabIndex="3" Width="762px" 
                        AutoGenerateColumns="False">
                        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                        <Columns>
                            <asp:BoundField DataField="TicketID" HeaderText="TicketID" SortExpression="TicketID" />
                            <asp:BoundField DataField="Reception Number" HeaderText="Reception Number" SortExpression="Reception Number" />
                            <asp:BoundField DataField="Submitted By" HeaderText="Submitted By" SortExpression="Submitted By" />
                            <asp:BoundField DataField="Submit Date" HeaderText="Submit Date" 
                                SortExpression="Submit Date" />
                            <asp:BoundField DataField="Update Type" HeaderText="Update Type" SortExpression="Update Type" />
                            <asp:BoundField DataField="Brief Desc" HeaderText="Brief Desc" 
                                SortExpression="Brief Desc">
                            </asp:BoundField>
                            <asp:BoundField DataField="Submiters Comments" HeaderText="Submiters Comments" 
                                SortExpression="Submiters Comments" />
                            <asp:BoundField DataField="Complete" HeaderText="Complete" 
                                SortExpression="Complete" />
                            <asp:BoundField DataField="Schedule Count" HeaderText="Schedule Count" 
                                SortExpression="Schedule Count" />
                            <asp:TemplateField HeaderText="test templet">
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("Archived") %>' 
                                        AutoPostBack="True" oncheckedchanged="CheckBox2_CheckedChanged" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                        <EditRowStyle Wrap="False" />
                        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                    </asp:GridView>

Open in new window

Avatar of sabev
sabev

ASKER

Or, if when CheckBox_CheckedChanged event is fired, if I could determine the row of the GridView the checkbox is in, that would be even better.  It should have some parent and location information, shouldn't it?

thanks
Avatar of sabev

ASKER

(Notes for the OP):

The original databinding problem is not so much an issue as getting the RowIndex when the checkbox is changed.

hmm....  I have tried adding onRowCommand="MyDataGrid_EditCommand" to the <asp:GridView object, hoping it would call the code behind "MyDataGrid_EditCommand" sub routine when the checkbox is checked but it does not call it.

It does not seem like I can pass the RowIndex on the CheckBox_CheckedChanged event.

Is there some event within the GridView that I can get to fire when a checkbox located in a template is checked?

I've tried -
OnRowCommand
OnRowEditing
OnRowUpdating

With no luck.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of sabev
sabev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial