Disable radgrid label message on page load

5 posts, 1 answers
  1. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 02 Jul 2015 Link to this post

    Hi

    I design radgrid with advanced databinding.I want to show label message when radgrid is empty and is working perfectly fine but problem is that its also showing in the page load .radgrid bind with button click event if no data found then message will be display. ..by default radgrid shows message but its "No records to display "but its also visible on page load and radgrid dispersal on each post back ...i am working in user control in DNN here..Please suggest anyone how hide my label text in page load ...Thanx in advanced here my code

     protected void Page_Load(object sender, EventArgs e)
            {
               
                if (!Page.IsPostBack)
                {

                    billingRadGrid.Visible = true;
                }
                 
                    BindComboBox();
                    //lblMessage.Text = string.Empty;
                    lblMessage.Visible = true;
                }

    protected void billingRadGrid_OnNeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                billingRadGrid.DataSource = GetGridTable();
            }
            public DataTable GetGridTable()
            {
                Decimal amount_from;
                if (!Decimal.TryParse(amountFromTb.Text, out amount_from))
                {
                    amount_from = 0;
                }
                Decimal amount_to;
                if (!Decimal.TryParse(amountToTb.Text, out amount_to))
                {
                    amount_to = 0;
                }
                Decimal duration_from;
                if (!Decimal.TryParse(durationFromTb.Text, out duration_from))
                {
                    duration_from = 0;
                }
                Decimal duration_to;
                if (!Decimal.TryParse(durationToTb.Text, out duration_to))
                {
                    duration_to = 0;
                }
                string dateFrom = DateFromTb.Text;
                DateTime dateF = DateTime.ParseExact(dateFrom, "yyyy-MM-dd", null);
                string dateTo = DateToTb.Text;
                DateTime dateT = DateTime.ParseExact(dateTo, "yyyy-MM-dd", null);
                DataController dc = new DataController();
                BillingDetail bill = new BillingDetail();
                bill.accountNumber = "12004572";
                bill.fromDate = dateF;
                bill.toDate = dateT;
                bill.amountFrom = Convert.ToDecimal(amount_from);
                bill.amountTo = Convert.ToDecimal(amount_to);
                bill.durationFrom = Convert.ToDecimal(duration_from);
                bill.durationTo = Convert.ToDecimal(duration_to);
                bill.traficType = trafictypeCombo.SelectedItem.Text;
                bill.terminateState = stateNameTb.Text;
                bill.number = bTNComboBox.SelectedValue;
                bill.lineType = lineTypeComboBox.SelectedItem.Text;
                bill.dialedNum = Convert.ToString(dialedNumber.Text);
                DataTable dtBill = dc.GetUsageDetail_bill(bill);
                if (dtBill.Rows.Count > 0)
                {

                    billingRadGrid.Visible = true;
                    lblMessage.Text = string.Empty;
                    lblMessage.Visible = false;
                }
                else
                {

                    lblMessage.Visible = true;
                    billingRadGrid.Visible = false;
                    lblMessage.Text = "No Records To Display";
                    lblMessage.ForeColor = Color.Red;
                }
                return dtBill;
            }

  2. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 02 Jul 2015 in reply to Mukul Link to this post

     i want to correct my above code...i also tried out this on page load

     lblMessage.Visible = false;

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 03 Jul 2015 Link to this post

    Hi.

    telerik team help me for resolve my issue...thnanks

     
  5. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 06 Jul 2015 Link to this post

    Hi Mukul,

    If you want to hide the Label control on the initial page load you can use the following code within the Page's PreRender event:
    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            lblMessage.Visible = false;
        }
    }

    Another approach would be to add the above condition at the end of your GetGridTable method.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Mukul
    Mukul avatar
    12 posts
    Member since:
    Jan 2015

    Posted 06 Jul 2015 in reply to Konstantin Dikov Link to this post

    Thank you very much Konstantin,

    its work for my code and running successfully

    thanks

    Mukul

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017