Hi Everyone,

   I am trying to do the paging and sorting in the datagrid. I 
implemented both of them,Paging seems to be working fine,
 but due to some reason. Whenever I click on the top link, of the 
datagrid column. Content of the data disappaers.

This is the code that I wrote

        private void DgReportResult_SortCommand(object source, 
System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
                {
                        ViewState.Add("sortfield", e.SortExpression);
                        
                        
                                if (ViewState["sortdirection"]
==null )
                                {
                                        ViewState.Add
("sortdirection", "ASC");
                                }
                                else
                                
                                        if (ViewState
["sortdirection"]== "ASC")
                                        {

                                                ViewState
["sortdirection"]="DESC";
                                        }
                                else
                                { 
                                        ViewState["sortdirection"]
="ASC";

                                }
                        BindGrid();
                }

        private void DgReportResult_PageIndexChanged(object source, 
System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
                {
                        DgReportResult.CurrentPageIndex = 
e.NewPageIndex;
                        BindGrid();
                }


void BindGrid()
                {
                        
                        
                        newsrchreturns = (DataView)Session
["RepResults"];
                        if (ViewState["sortfield"] != null)
                        {
                                newsrchreturns.Sort = ViewState
["sortfield"] + " " + ViewState["sortdirection"];
                        }
                                DgReportResult.DataSource= 
newsrchreturns;
                                DgReportResult.DataBind();

<asp:datagrid id="DgReportResult" runat="server" AllowPaging="True" 
AutoGenerateColumns="false"
                                                
        AllowSorting="True" >
<columns>
        <asp:BoundColumn DataField="AM" HeaderText="AM" 
SortExpression="AM"></asp:BoundColumn>
</columns>

I have other columns too. When I click on AM - DataField. The 
contents of AM in the datagrid disappears.

Please let me know what am I doing wrong.

Thanks





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to