Hi,
Thanks for your feedback.
After downloading the source code of that MSDN article, I can reproduce out
the can not sorting issue.
After doing some research, I found that this is a little problem of the
implementation of that DropDownColumn. Normally, in
DataGridCell.InitializeCell() method, it internally will check if sorting
is enabled, then place a LinkButton control in the HeaderRow of that
column. However, in the implementation of DropDownColumn, it writes code
like this:
Select Case itemType
Case ListItemType.Header
cell.Text = HeaderText
Case ListItemType.Item, ListItemType.AlternatingItem
.....
End Select
As we can see that, it place a text string in the DataGridCell(cell), then
this string will in front of the LinkButton and blocked it. So we can not
see the sorting LinkButton.
To workaround this issue, we can just determine the sorting condition, then
do not place headertext for sorting, like this:
Select Case itemType
Case ListItemType.Header
If Me.Owner.AllowSorting = True And Me.SortExpression <> Nothing
And Me.SortExpression <> String.Empty Then
Else
cell.Text = HeaderText
End If
Case ListItemType.Item, ListItemType.AlternatingItem
........
End Select
After this modification, the LinkButton will appear when we enabling
sorting.
For the HeaderStyle issue, it seems that it works well on my side. For
example, if I set HeaderStyle-ForeColor="Red" in DropDownColumn, the string
text color will become red in the page, like this:
<asp
ataGrid id="DataGrid1" AllowSorting="True" runat="server"
CssClass="grid" AutoGenerateColumns="False">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="OrderID" SortExpression="OrderID"
ReadOnly="True" HeaderText="Order ID"></asp:BoundColumn>
<asp:BoundColumn DataField="ShipName" ReadOnly="True" HeaderText="Ship
to"></asp:BoundColumn>
<asp:BoundColumn DataField="ShipCountry" ReadOnly="True"
HeaderText="Country"></asp:BoundColumn>
<dgg
ropDownColumn HeaderStyle-ForeColor="Red" SortExpression="ShipVia"
DataField="ShipVia" DataTextField="CompanyName" DataValueField="ShipperID"
HeaderText="Ship Method">
</dgg
ropDownColumn>
</Columns>
</asp
ataGrid>
==================================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.