Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:17:53+00:00 2026-06-09T14:17:53+00:00

From the title above, my code at the first time page_load, there is no

  • 0

From the title above, my code at the first time page_load, there is no problem, it show correctly but after I click button to change language, it is disappear(only show header). I spend about one week to find out but still cannot find what happen.
If the visible data MORE than 1, its working properly.

EDIT:
Forgot to put my page Load method

    protected void Page_Load(object sender, EventArgs e)
    {
        NoResult.Visible = false;
        Get_Data();
    }

    protected void Get_Data()
    {

        DBCAD.Service1 myCADDB = new DBCAD.Service1();
        myCADDB.UseDefaultCredentials = true;
        string result = "";
        //set web service proxy
        if (!GlobalVariable_CCCNS.filterOrNot)
        {
            //invoke web service method
            result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
        }
        else
        {
            GlobalVariable_CCCNS.FilterDC = DropDownList1.SelectedValue;
            //invoke web service method
            if (GlobalVariable_CCCNS.FilterDC == "CCC NS ALL")
            {
                result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
             }
            else
            {                  
                result = myCADDB.CallCardStatus_Filter(GlobalVariable_CCCNS.FilterDC);
            }
        }

        //read the response data and put in xml document
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(result);
        string mypath = Server.MapPath(@"Data.xml");

        //XmlTextReader reader = new XmlTextReader ("DBCAD.xml");
        xmlDoc.Save(mypath);

        //set the data set
        DataSet ds = new DataSet();

        ds.ReadXml(mypath);

        //Open hidden column
        CallCardStatus.Columns[0].Visible = true;

        if (ds.Tables.Count > 0)
        {
            //list out the result to Data Grid
            CallCardStatus.DataSource = ds;
            CallCardStatus.DataBind();
        }
        else
        {
            NoResult.Visible = true;
        }

        //Clear Unwanted Column
        CallCardStatus.Columns[0].Visible = false;
  }

Here is my RowDataBound

    string lastRow = "";
    protected void CallCardStatus_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //Many item with same id but different status, I just want to visible and get the first row for each id.
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var thisRow = e.Row;

            if (thisRow.Cells[0].Text == lastRow)
            {
                e.Row.Visible = false;
            }
            lastRow = thisRow.Cells[0].Text;
        }
    }

Here is my RadioButton for Language Malay and English

    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GlobalVariable_CCCNS.cultureName = RadioButtonList1.SelectedValue.ToString();

        Page.Culture = GlobalVariable_CCCNS.cultureName;
        Page.UICulture = GlobalVariable_CCCNS.cultureName;
        if (GlobalVariable_CCCNS.cultureName == "ms-MY")
        {
            Label2.Visible = false;
            Label2.Text = "Kawalan Status Kad Panggilan";
            Label2.Visible = true;
        }
        else
        {
            Label2.Visible = false;
            Label2.Text = "CallCard Status Monitoring";
            Label2.Visible = true;
        }

        Page_Render();
    }


    protected void Page_Render()
    {
        Page.Culture = GlobalVariable_CCCNS.cultureName;
        Page.UICulture = GlobalVariable_CCCNS.cultureName;
        ALL.Text = GetLocalResourceObject("ALLResource1.Text").ToString();
        Label1.Text = GetLocalResourceObject("Label1Resource1.Text").ToString();
        NoResult.Text = GetLocalResourceObject("NoResultResource1.Text").ToString();

        DBCAD.Service1 myCADDB = new DBCAD.Service1();
        myCADDB.UseDefaultCredentials = true;
        string result = "";
        //set web service proxy
        if (!GlobalVariable_CCCNS.filterOrNot)
        {
            //invoke web service method
            result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
        }
        else
        {
            GlobalVariable_CCCNS.FilterDC = DropDownList1.SelectedValue;
            //invoke web service method

            if (GlobalVariable_CCCNS.FilterDC == "CCC NS ALL"){
                    result = myCADDB.CallCardStatus_Filter_CCCNSEMBILAN_ALL();
            }else{
                    //invoke web service method
                    result = myCADDB.CallCardStatus_Filter(GlobalVariable_CCCNS.FilterDC);
            }
        }

        //read the response data and put in xml document
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(result);
        string mypath = Server.MapPath(@"Data.xml");

        //XmlTextReader reader = new XmlTextReader ("DBCAD.xml");
        xmlDoc.Save(mypath);

        //set the data set
        DataSet ds = new DataSet();

        ds.ReadXml(mypath);
        // CallCardStatus.DataSource = ds;
        //CallCardStatus.DataBind();

        //Open hidden column
        CallCardStatus.Columns[0].Visible = true;

        if (ds.Tables.Count > 0)
        {
            //list out the result to Data Grid
            CallCardStatus.DataSource = ds;
            CallCardStatus.Columns[2].HeaderText = GetLocalResourceObject("ButtonFieldResource1.Text").ToString();
            CallCardStatus.Columns[3].HeaderText = GetLocalResourceObject("BoundFieldResource3.HeaderText").ToString();
            CallCardStatus.Columns[4].HeaderText = GetLocalResourceObject("BoundFieldResource4.HeaderText").ToString();
            CallCardStatus.Columns[5].HeaderText = GetLocalResourceObject("BoundFieldResource5.HeaderText").ToString();
            CallCardStatus.Columns[6].HeaderText = GetLocalResourceObject("BoundFieldResource6.HeaderText").ToString();
            CallCardStatus.Columns[7].HeaderText = GetLocalResourceObject("BoundFieldResource7.HeaderText").ToString();
            CallCardStatus.Columns[8].HeaderText = GetLocalResourceObject("BoundFieldResource8.HeaderText").ToString();
            CallCardStatus.Columns[9].HeaderText = GetLocalResourceObject("BoundFieldResource9.HeaderText").ToString();
            CallCardStatus.DataBind();
        }
        else
        {
            NoResult.Visible = true;
        }

        //Clear Unwanted Column
        CallCardStatus.Columns[0].Visible = false;
     }

Anyone can help?Thanks..Siti..:)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:17:55+00:00Added an answer on June 9, 2026 at 2:17 pm

    In order to clean up your legacy code a little bit, I recommend you the following: (cleaning your code will help u to spot the error easier)

    Binding your GridView

    The best practice to bind a data-bound control is inside the Page_Load event:

    protected void Page_Load(object sender, EventArgs e)
    {
         if (!this.IsPostBack)
         {
             // in this method u will bind your GridView
             this.BindGrid();
         }
    }
    

    Unless I’m missing something, the code inside the Page_Render method is used to render your GridView, and that code is duplicated in the Get_Data method. You could place the code specific to bind your GridView inside one single method.

    Now you only need to re-bind your GridView when its content has changed, for example if you allow your users to edit your GridView records. Otherwise, you should not re-bind it. (This is true, as long as your page has EnableViewState="true")

    The code to localize your GridView columns can be moved to the GridVew.DataBound event. Or even better, delegate the logic to localize the view to your markup, to do it, you could create templated columns in your GridView.

    Example:

        <asp:GridView runat="server" DataSourceID="lds" ID="gv"
            AutoGenerateColumns="false"
        >
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:Label Text="<%$ Resources: your_resource_file_name_without_extension, your resource_key %>" runat="server" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="a_meaningfull_name" Text='<%# Eval("your_field_name") %>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    

    Set the page language overriding the Page.InitializeCulture method:

    Note that you only need to set this.UICulture = culture; and this.Culture = culture; inside this method

    protected override void InitializeCulture()
    {
        // you have to call Request.Form, because at this point in the page life cycle, the page viewstate has not been loaded yet
        var culture = this.Request.Form["RadioButtonList1"];
    
        if (!string.IsNullOrWhiteSpace(culture))
        {
            // if the values of your list are culture specific (ie. en-US, es-MX, etc) you can uncomment the following line
            // this.Culture = culture;
            this.UICulture = culture;
            base.InitializeCulture();
        }
    }
    

    Using this approach you do not need the RadioButtonList1_SelectedIndexChanged event. The code you are placing inside this event won’t be necessary.

    This code:

        if (GlobalVariable_CCCNS.cultureName == "ms-MY")
        {
            Label2.Visible = false;
            Label2.Text = "Kawalan Status Kad Panggilan";
            Label2.Visible = true;
        }
        else
        {
            Label2.Visible = false;
            Label2.Text = "CallCard Status Monitoring";
            Label2.Visible = true;
        }
    

    Can be easily eliminated using markup: (note that you will need to create one resource file for each language you want to use in your application, to learn more about ASP.Net Globalization click here)

    Using global resources

    <!-- Assuming global resources -->
    <asp:Label runat="server" ID="Label2" Text="<%$ Resources: your_resource_file_name_without_extension, your_resource_key %>"  />
    

    Your global resource file would look like:

      <data name="your_resource_key" xml:space="preserve">
        <value>your text</value>
      </data>
    

    Using local resources

    <!-- Assuming local implicit resources -->
    <asp:Label runat="server" ID="Label2" meta:resourcekey="base_name_of_your_resource_key" Text="default value used to render the control at design time in VS" />
    

    In this case, your local resource file would look like:

      <data name="base_name_of_your_resource_key.Text" xml:space="preserve">
        <value>your text</value>
      </data>
    

    You do not need to call Page_Render(); in the RadioButtonList1_SelectedIndexChanged event

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function above to create url slugs from posts title, the problem
As you can understand from title, i modified Settings.cs file.Added some properties, some code
As title says, mock code to demostrate my problem Driver Class import java.io.*; public
I'm getting some strange behaviour from EF Code First when I add an object
as from Title.
The question from title doesn't need more details.
From the title of a music, a try toget the corresponding Artist, ALbum's name
SELECT events.title FROM events ORDER BY events.title DESC I'm getting the proper ordering for
Pretty clear from the title itself, what is meant by porting an application X
I want to retrieve website title from webview cookies of my application. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.