This is a migrated thread and some comments may be shown as answers.

Disable radgrid label message on page load

4 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mukul
Top achievements
Rank 1
Mukul asked on 02 Jul 2015, 01:51 PM

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;
        }

4 Answers, 1 is accepted

Sort by
0
Mukul
Top achievements
Rank 1
answered on 02 Jul 2015, 01:59 PM

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

 lblMessage.Visible = false;

0
Mukul
Top achievements
Rank 1
answered on 03 Jul 2015, 07:59 AM

Hi.

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

 
 
 
 
0
Accepted
Konstantin Dikov
Telerik team
answered on 06 Jul 2015, 10:19 AM
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
0
Mukul
Top achievements
Rank 1
answered on 06 Jul 2015, 03:07 PM

Thank you very much Konstantin,

its work for my code and running successfully

thanks

Mukul

Tags
General Discussions
Asked by
Mukul
Top achievements
Rank 1
Answers by
Mukul
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or