I have a gridview with a check-box column.Evidently, each row will then have its own checkbox field. what am trying to achieve is to have only the topmost checkbox selected, preferably using javascript. Ive searched for this but everybody seems to rely on a button click to select all/ deselect all.
Am manipulating the datasource attached to the grid, so i need it to display the checkbox on the first row selected.
Ideas?
<asp:GridView ID="gridRoutes" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="odsRoutes" onrowdatabound="gridRoutes_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk_selector" runat="server" AutoPostBack="true" OnCheckedChanged="chk_selector_CheckedChanged" Checked="false"/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Number" HeaderText="Number"
SortExpression="Number" />
<asp:BoundField DataField="StartAddress" HeaderText="StartAddress"
SortExpression="StartAddress" />
<asp:BoundField DataField="EndAddress" HeaderText="EndAddress"
SortExpression="EndAddress" />
<asp:BoundField DataField="StopTime" HeaderText="StopTime"
SortExpression="StopTime" />
</Columns>
</asp:GridView>
If you’re happy to do it in jQuery, this should do the trick: