DataGrid is in the editable mode. The rest of the columns in the
DataGrid are TemplateColumns . There's an EditCommandColu mn as well.
All the columns including the BoundColumn but excluding the
EditCommandColu mn can be sorted. The column sorted is also accompanied
by an image to indicate whether a column has been sorted ascendingly
or descendingly. The image gets rendered when the ItemDataBound event
of the DataGrid fires. This is the DataGrid:
<asp:DataGrid ID="dgCart"
OnEditCommand=" EditCart"...OnI temDataBound="B indCart" runat="server">
<asp:TemplateCo lumn>
<HeaderTemplate >
<asp:LinkButt on ID="lnkPID" CommandArgument ="PID" Text="ID"
runat="server"/> <img id="imgPID" src="Up.gif" visible="false"
runat="server"/>
</HeaderTemplate>
<ItemTemplate >
<asp:Label ID="lblPID" Text='<%# Container.DataI tem("PID") %>'
runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:TemplateCo lumn>
<HeaderTemplate >
<asp:LinkButt on ID="lnkPName" CommandArgument ="PName" Text="PRODUCT"
runat="server"/> <img id="imgPName" src="Up.gif" visible="false"
runat="server"/>
</HeaderTemplate>
<ItemTemplate >
<asp:Label ID="lblPName" Text='<%# Container.DataI tem("PName") %>'
runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
<%-- a few more TemplateColumns as shown above come here --%>
<asp:BoundColum n DataField="Qty" HeaderText="QTY " SortExpression= "Qty"/
><asp:EditComman dColumn CancelText="CAN CEL" EditText="EDIT"
HeaderText="EDI T" UpdateText="UPD ATE"/>
</asp:DataGrid>
The problem is when the DataGrid is sorted by the QTY column
irrespective of whether the DataGrid is in the editable mode or not, I
can't seem to find a way to render the image along with the HeaderText
*QTY* since it's a BoundColumn.
Is there any way by which I can make the HeaderText display the image
when the DataGrid is sorted by the QTY column?
Replacing the BoundColumn with a TemplateColumn, adding a TextBox in
the ItemTemplate of the TemplateColumn & making it visible/invisible
as & when the EDIT button is clicked could be one option but that I
guess would entail a lot of additional code to make the TextBox
corresponding to the row in which the EDIT button is clicked visible.