[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

How to sort datakeynames in gridview

Asked by einnox in Active Server Pages (ASP), Dynamic HTML (DHTML), Macromedia Homesite

Tags: Gridview, datakeyname, paging, sorting

I have a gridview, it allow sorting ang paging, it has a check box where i detect the the unique id, all works fine, except when the gridview was sort, and i edit the particular record which is checked, wrong data appeared because the previeous data retrieve, it doesnt update the datakeyname which the checkbox holds so wrong data display.

Please help me with this matter, all of my pages use this technique and i have a dealine right now.

Thanks in advance.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                            AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" 
                            BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="ID" 
                            EnableViewState="False" GridLines="Horizontal" 
                            Style="position: relative; top: 0px; left: 5px; height: 153px; width: 718px;" 
                            onpageindexchanging="GridView1_PageIndexChanging" AllowSorting="True" 
                            onsorting="GridView1_Sorting" EmptyDataText="No Record Found.">
                            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                            <RowStyle BackColor="#CCCCCC" ForeColor="#4A3C8C" />
                            <Columns>
                                <asp:TemplateField><HeaderTemplate><input ID="chkAll" runat="server" 
                                            onclick="javascript:SelectAllCheckboxes(this);" type="checkbox"/></HeaderTemplate><ItemTemplate><asp:CheckBox ID="PageID" runat="server" /></ItemTemplate><ControlStyle Width="50px" /><ItemStyle HorizontalAlign="Center" Width="20px" /></asp:TemplateField>
                              <asp:BoundField DataField="Name" SortExpression="Name" HeaderText="Name"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>
                                <asp:BoundField DataField="TempName" SortExpression="TempName" HeaderText="Template"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>
                                <%--<asp:BoundField DataField="CatName" SortExpression="CatName" HeaderText="Category"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>--%>
                                <asp:BoundField DataField="CouName" SortExpression="CouName" HeaderText="Country"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>
                                <asp:TemplateField HeaderText="Status" SortExpression="Status"><ItemTemplate><asp:Image ID="imgButton" runat="server" ImageUrl='<%# (string) FormatImageUrl( (string) Eval("Status")) %>' Width="20" Height="20"></asp:Image></ItemTemplate></asp:TemplateField>
                                <asp:BoundField DataField="Author" SortExpression="Author" HeaderText="Author"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>
                                <asp:BoundField DataField="Description" SortExpression="Description" HeaderText="Description"><HeaderStyle HorizontalAlign="Left" /></asp:BoundField>
                            </Columns>
                            <PagerStyle BackColor="Gray" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                            <HeaderStyle BackColor="#666666" Font-Bold="True" ForeColor="#F7F7F7" />
                            <AlternatingRowStyle BackColor="#F7F7F7" />
                        </asp:GridView>
 
Related Solutions
Keywords: How to sort datakeynames in gridview
 
Loading Advertisement...
 
[+][-]04/21/09 04:39 AM, ID: 24193133Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/09 06:13 PM, ID: 24200755Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625