Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
76 views
I have a scenario as below.
There are 3 check boxes.3 textbox associated with each.Grid gets populated on entering a search value in the textbox.On selecting a row on this grid,I need to hide the grid and selected value(one column) is populated into another textbox.I am getting "Object reference not set to an instance of an object.",when I implementing the logic for hiding the grid.Checkbox checked,value entered in search textbox,grid is populated ,a row selected,second textbox populated with grid value,grid gets hidden--> after this process repeated for 2-3 times,again checking on a check box gives the error.
Please find the markup with above controls.

<table width="500px">
           <tr>
               <td>
                   <fieldset id="fssearch" runat="server">
                       <legend>Search </legend>
                       <table>
                           <tr>
                               <td>
                                   <asp:CheckBox ID="CBFile" runat="server" Text="File No" OnCheckedChanged="CBFile_CheckedChanged"
                                       AutoPostBack="true" />
                               </td>
                               <td>
                                   <asp:CheckBox ID="CBname" runat="server" Text="Patient Name" OnCheckedChanged="CBname_CheckedChanged"
                                       AutoPostBack="true" />
                               </td>
                               <td>
                                   <asp:CheckBox ID="CBMobile" runat="server" Text="Mobile No" OnCheckedChanged="CBMobile_CheckedChanged"
                                       AutoPostBack="true" />
                               </td>
                           </tr>                    
                       
                        
                           <tr>                           
                               <td>
                                <asp:TextBox ID="RTFileS" onkeyup="KeyUp();" runat="server" OnTextChanged="RTFileS_TextChanged" Visible="false"></asp:TextBox>                                 
                               </td>
                               <td colspan="2">
                                   <asp:TextBox ID="RTNameS" onkeyup="KeyUp();" runat="server" OnTextChanged="RTNameS_TextChanged" Visible="false"></asp:TextBox>                                 
                               </td>
                               <td>
                                   <asp:TextBox ID="RTMobileS" onkeyup="KeyUp();" runat="server" OnTextChanged="RTMobileS_TextChanged" Visible="false"></asp:TextBox>                               
                               </td>                          
                           </tr>
                           <tr>
                               <td colspan="4">                                                                 
                                   <telerik:RadGrid ID="gvPatientList" runat="server" AllowFilteringByColumn="True"
                                       AllowPaging="True" GridLines="None" OnSelectedIndexChanged="gvPatientList_SelectedIndexChanged" >
                                       <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
                                       <GroupingSettings CaseSensitive="false" />
                                       <ItemStyle HorizontalAlign="Left" />
                                       <HeaderStyle HorizontalAlign="Left" />
                                       <AlternatingItemStyle HorizontalAlign="Left" />
                                       <ClientSettings EnablePostBackOnRowClick="true">
                                           <Selecting AllowRowSelect="true" />
                                       </ClientSettings>
                                       <MasterTableView AutoGenerateColumns="False" DataKeyNames="pt_regid">
                                           <CommandItemTemplate>
                                               <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                                           </CommandItemTemplate>
                                           <Columns>
                                               <telerik:GridBoundColumn HeaderText="Patient Name" UniqueName="pt_name" DataField="pt_name"
                                                   AllowFiltering="false">
                                               </telerik:GridBoundColumn>
                                               <telerik:GridBoundColumn HeaderText="File No" UniqueName="pt_fileno" DataField="pt_fileno"
                                                   AllowFiltering="false">
                                               </telerik:GridBoundColumn>
                                               <telerik:GridBoundColumn HeaderText="Mobile" UniqueName="pt_pmobileno" DataField="pt_pmobileno"
                                                   AllowFiltering="false">
                                               </telerik:GridBoundColumn>
                                           </Columns>
                                       </MasterTableView>
                                       <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
                                       </HeaderContextMenu>
                                   </telerik:RadGrid>                                   
                               </td>
                           </tr>
                       </table>
                       </fieldset>
               </td>
           </tr>
       </table>


On selecting a row on the grid,I am populating name column value to a textbox  and hiding the grid as below.
protected void gvPatientList_SelectedIndexChanged(object sender, EventArgs e)
    {
 
        GridDataItem RegId = gvPatientList.SelectedItems[0] as GridDataItem;
         string regid = RegId.GetDataKeyValue("pt_regid").ToString();
         
 
         
        foreach (GridDataItem dataItem in gvPatientList.Items)
        {
            if (dataItem.Selected)
            {
                RCFName.Text = dataItem["pt_name"].Text;              
            }
        }
        gvPatientList.Visible = false;             
         
    }


Above mentioned checkboxes act like radio buttons and javascript for the same is as below
<script language="CS" runat="server">
        private void makeRadioGroupFromCheckBoxes(IEnumerable<CheckBox> checkBoxes)
        {
            StringBuilder sb = new StringBuilder();
            foreach (CheckBox cb in checkBoxes)
            {
                foreach (CheckBox innercb in checkBoxes)
                {
                    if (innercb != cb)
                    {
                        sb.Append("document.getElementById('");
                        sb.Append(innercb.ClientID);
                        sb.Append("').checked = false;");
                    }
                }
                cb.Attributes["onclick"] = "if(this.checked){" + sb.ToString() + "}else{this.checked = true;}";
 
                sb = new StringBuilder();
            }
        }      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.makeRadioGroupFromCheckBoxes(new CheckBox[] { CBFile, CBname, CBMobile });              
            }
        }
Grid gets populated on textchanged event and 'onkeyup="KeyUp();' function of the textbox,associated with it as below.
aspx:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var timer = null;
            function KeyUp() {
                if (timer != null) {
                    clearTimeout(timer);
                }
                timer = setTimeout(LoadTable, 500);
            }
            function LoadTable() {
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("FilterGrid");
            }
         
        </script>
    </telerik:RadCodeBlock>
code behind:
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
       {
           if (e.Argument.IndexOf("FilterGrid") != -1)
           {
               gvPatientList.Rebind();
           }
       }
 
       protected void RTFileS_TextChanged(object sender, EventArgs e)
       {
           if (!string.IsNullOrEmpty(RTFileS.Text))
           {
                
               _scheduleService = new ScheduleService();
               clsSchedule clsschedule = new clsSchedule();
               string search = " where OldRegnNo like '" + RTFileS.Text + "%" + "'";
               gvPatientList.DataSource = _scheduleService.GetAllPatients(search);
               //gvPatientList.MasterTableView.Rebind();
               gvPatientList.Rebind();
           }
       }
On checkedchanged eveent of check boxes,I am making the grid visible.
protected void CBFile_CheckedChanged(object sender, EventArgs e)
   {
       if (CBFile.Checked)
       {
           RTFileS.Visible = true;
           gvPatientList.Visible = true;
           gvPatientList.MasterTableView.Visible = true;
           gvPatientList.Rebind();
          
       }
       else
       {
           RTFileS.Visible = false;
       }
   }

Ajaxmanager is as below:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
       <AjaxSettings>
           <telerik:AjaxSetting AjaxControlID="gvPatientList">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="gvPatientList" LoadingPanelID="RadAjaxLoadingPanel1" />
                   <telerik:AjaxUpdatedControl ControlID="RCFName" />
                   <%--<telerik:AjaxUpdatedControl ControlID="CBFile" />
                   <telerik:AjaxUpdatedControl ControlID="CBname" />
                   <telerik:AjaxUpdatedControl ControlID="CBMobile" />--%>
               </UpdatedControls>
           </telerik:AjaxSetting>
           <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
               <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="gvPatientList" LoadingPanelID="RadAjaxLoadingPanel1" />
               </UpdatedControls>
           </telerik:AjaxSetting>

I hope hiding/unhiding the grid gives me the error.Please suggest your ideas on this.
Thanks,
Soumya
Marin
Telerik team
 answered on 28 Aug 2012
1 answer
118 views
I am having the hardest time getting a RadButton to invoke a function in the code-behind file, which updates the text of the RadButton.  So far I can get the button to fire with Ajax, but even though the function changes the text it is not reflected back onscreen.  Furthermore, the 2nd time I click the button the page conducts a postback resulting in a view that only shows the contents of the master page.  The content of the web form is blank.

Am I missing or have incorrect parameters?

Web Form RadAjaxPanel + RadButton
<telerik:RadAjaxPanel ID="Panel_MyList" RestoreOriginalRenderDelegate="true" LoadingPanelID="RadAjaxLoadingPanel_MyList" runat="server">
    <telerik:RadButton UseSubmitBehavior="true" AutoPostBack="true" EnableAjaxSkinRendering="false" EnableEmbeddedSkins="false" EnableTheming="false" EnableBrowserButtonStyle="false" EnableEmbeddedBaseStylesheet="false" ButtonType="LinkButton" ID="Button_MyList" OnClick="Button_MyList_OnClick" runat="server" Text="Add to Favorites" CssClass="btn btn-view" style="font-size:18px;"></telerik:RadButton>
</telerik:RadAjaxPanel>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel_MyList" runat="server" />

Web Form RadAjaxManagerProxy
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy_Tour" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button_MyList" EventName="Click">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Button_MyList" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>

Master Page RadScriptManager + RadAjaxManager
    <telerik:radscriptmanager ID="Radscriptmanager1" EnablePartialRendering="true" EnablePageMethods="true" ScriptMode="Debug" runat="server"></telerik:radscriptmanager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" EnableAJAX="true" runat="server" />








Eyup
Telerik team
 answered on 28 Aug 2012
11 answers
417 views
First of all I am very new to ASP.NET. Been writing classic ASP for 10 years.
I have a very basic insert form that is submitting to a sql database named "Users", table named "tblUsers".. I have a field named "ImageName" that I am trying to get the file name to post to when the form is submited. The image uploads but I cannot figure out how to make the file name post to the database. I am using RadUpload and I figured you could bind the field to the database column just like you do the text fields. But I don't see how. This is all very new to me. Thanks
Peter Filipov
Telerik team
 answered on 28 Aug 2012
0 answers
68 views
Hi,
i have a problem regarding Redscheduler .
i have written custom theme for my project.
Every thing is fine in Chrome and FireFox but in IE8 theme is not working properly on one the my pages that contains RadScheduler.
css not working on radschduler in ie8.

Help me resolve this problem.
Kamran
Top achievements
Rank 1
 asked on 28 Aug 2012
1 answer
59 views
We have purchased the Developer Tools package and I need to generate an asp.net web page that displays a report that looks similar to the attached image. I would like to use the reporting tools as we want to be able to export and print easily, but I'm having some trouble determining the best way to do this. It seems that the gridview would be a better option, but it doesn't look like there is an easy way to export and/or print the radgrid...is there?

The rows with month names are to be expanded and collapsed when the user clicks on them. What would be the best way for me to approach this using the Telerik Developer tools?

Thanks in advance.
Steve
Telerik team
 answered on 28 Aug 2012
0 answers
69 views
How   to  label   data  with  "radmap"???

Quetion  one:
     How   to  use  a  pins   which   has  a  tag   to    mark   information???


Quetion  two:

     How   to  mark   the    "Energy  consumption   data"    and    "Water    consumption   data"   on  every  building  of  the  map???   
     Such  as  the  picture  attechment...

    The  picture... 
Yostec
Top achievements
Rank 1
 asked on 28 Aug 2012
2 answers
70 views
hii,
how to disable filter while editing?

thanks
Jayesh Goyani
Top achievements
Rank 2
 answered on 28 Aug 2012
1 answer
80 views
hii,,
I want to make a cloumn readonly in editing only not in insert mode,can you help me?

thanks

Jayesh Goyani
Top achievements
Rank 2
 answered on 28 Aug 2012
1 answer
259 views
I have already trie a bunch of the solutions on the forum, but none of them seem to work.  I have a Grid control with a Detail Table contained therein.  No matter what I have tried, I cannot hide the column in the detail table.  Could it be due to the fact that the column is the data key?
<telerik:RadGrid ID="grdAgingReport" Skin="WebBlue" EnableEmbeddedSkins="false" ShowStatusBar="true" OnSortCommand="grdAgingReport_SortCommand" OnPageIndexChanged="grdAgingReport_PageIndexChanged"
Width="97%" OnPageSizeChanged="grdAgingReport_PageSizeChanged" OnItemCommand="grdAgingReport_ItemCommand" OnDetailTableDataBind="grdAgingReport_DetailTableDataBind" OnPreRender="grdAgingReport_PreRender"
 AllowSorting="True" PageSize="15" AllowPaging="True" AllowMultiRowSelection="false" runat="server" Gridlines="Both" CssClass="RadGrid_WebBlue"  HierarchyLoadMode="ServerOnDemand">
 <ExportSettings HideStructureColumns="true"/>
 <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="MainCategory">
    <PagerStyle Mode="NextPrevAndNumeric" />
    <CommandItemSettings ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" />
    <DetailTables>
        <telerik:GridTableView DataKeyNames="SecondaryCategory" Name="grdTimePeriods" Width="90%" HierarchyLoadMode="ServerBind"></telerik:GridTableView>
    </DetailTables>
 </MasterTableView>   
</telerik:RadGrid>

protected void grdAgingReport_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
    if (e.DetailTableView.Name == "grdTimePeriods")
    {
        GridDataItem _GridDataItem = (GridDataItem)e.DetailTableView.ParentItem;
        string sMainCategory = _GridDataItem.GetDataKeyValue("MainCategory").ToString();
        e.DetailTableView.DataSource = BuildSecondaryTable(sMainCategory);
 
        //foreach (GridColumn _Column in e.DetailTableView.Columns)
        //    if (_Column.UniqueName.ToUpper() == "SECONDARYCATEGORY")
        //    {
        //        _Column.Display = false;
        //        break;
        //    }
    }
}
 
protected void grdAgingReport_PreRender(object source, EventArgs e)
{
    foreach (GridColumn _Column in grdAgingReport.MasterTableView.AutoGeneratedColumns)
    {
        switch (_Column.UniqueName.ToUpper())
        {
            case "MAINCATEGORY":
                _Column.Display = false;
                break;
        }
    }
 
    foreach (GridTableView _GridTableView in grdAgingReport.MasterTableView.DetailTables)
        if (_GridTableView.Name == "grdTimePeriods")
        {
            if (_GridTableView.Columns.Count > 0)
                _GridTableView.Columns[0].Visible = false;
            //foreach (GridColumn _Column in _GridTableView.Columns)
            //{
            //    if (_Column.UniqueName.ToUpper() == "SECONDARYCATEGORY")
            //        _Column.Display = false;
            //    break;
            //}
            break;
        }
}

       
Shinu
Top achievements
Rank 2
 answered on 28 Aug 2012
1 answer
79 views

I am new to telerik components. I have a telerik radgrid that retrieve data from sql server data source and does basic sorting. That sorting  does not work after I preserve radCombo values in server-side and put the radgrid code in !Ispostback(). I am aware that when grid header column is clicked for sorting, that time data gets posted back now and that is why the sorting is not working.  How to solve this issue and I don't want to take off the radgrid.datasource in page_load !Isposback().

 

if (!IsPostBack){
RadGrid1.Datasource = DataTable("select * from customer");
RadGrid1.DataBind();
}

 

Thanks in advance.

Shinu
Top achievements
Rank 2
 answered on 28 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?