Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
226 views

I have a radGrid with Add a Record turned on and the edit is turned on for each row.  How do I validate in the code behind if the user selected Add a Record or Edit an Existing?

I have a drop down list in the Insert and Edit modes.  If the user selects add a new record, I want to populate the drop dwon list with all the values and the first one should be selected.  If the user selects edit a record, I want the current value to display.  I am getting the latter one to work.

Protected Sub RadGrid1_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand  
        editSelected = True 
 
        Dim item As GridEditableItem = DirectCast(e.Item, GridEditableItem)  
        Dim statusLabel As Label  
        statusLabel = item.FindControl("lblStatus")  
        Session("updatedStatusValue") = statusLabel.Text.ToString()  
 
        Dim priorityLabel As Label  
        priorityLabel = item.FindControl("lblPriorityDesc")  
        Session("updatedPriorityValue") = priorityLabel.Text.ToString()  
 
    End Sub  
 
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
 
        If "matter".Equals(e.Item.OwnerTableView.Name) Then  
            If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then  
                Dim item As GridEditableItem = e.Item  
 
                Dim ddlStatusList As DropDownList = item.FindControl("ddlStatus")  
                ddlStatusList.DataSource = GetStatusList()  
                ddlStatusList.DataBind()  
 
                If (Not Session("updatedStatusValue") Is Nothing) Or editSelected Then  
                    For Each ddlItems As ListItem In ddlStatusList.Items  
                        If ddlItems.Text = Session("updatedStatusValue") And editSelected Then  
                            ddlStatusList.SelectedValue = ddlItems.Value  
                        End If  
                    Next  
                Else  
                    ddlStatusList.SelectedValue = 1 
                End If  
 
                Dim ddlPriorityList As DropDownList = item.FindControl("ddlPriorityDesc")  
                ddlPriorityList.DataSource = GetPriorityList()  
                ddlPriorityList.DataBind()  
 
                If (Not Session("updatedPriorityValue") Is Nothing) Or editSelected Then  
                    For Each ddlItems As ListItem In ddlPriorityList.Items  
                        If ddlItems.Text = Session("updatedPriorityValue") And editSelected Then  
                            ddlPriorityList.SelectedValue = ddlItems.Value  
                        End If  
                    Next  
                Else  
                    ddlPriorityList.SelectedValue = 1 
                End If  
 
            End If  
        End If  
    End Sub 

Thanks,

Randy

Princy
Top achievements
Rank 2
 answered on 30 Dec 2009
2 answers
151 views

I have a program that needs to call ajaxRequest from client side.
When I use this code in any aspx page, it works fine.
But when I put it into a DNN module,the $find method always return null.
Is there any difference in DNN module?

var ajaxManager = null;  
 
        function pageLoad() {  
            if (ajaxManager == null) {  
                ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");  
            }  
        }  
        function SuccessHandler(privateToken, alias, message) {  
            var datetime = new Date();  
            ajaxManager.ajaxRequest("(" + datetime.toLocaleTimeString() + ")");  
        } 
JC Wu
Top achievements
Rank 1
 answered on 30 Dec 2009
7 answers
425 views
I have a situation where a client is looking for a file explorer with the ability to map to locations that don't just lie under the root of the web directory.  This could mapped network drives, UNC paths etc.  Is it possible to specify those with this File Explorer and be able to use them?

Thanks
LG
Top achievements
Rank 2
 answered on 29 Dec 2009
2 answers
192 views
i binded a combobox with a sqldatasource and created a default selected value with combobox builder.I want to select default value for my combobox is "--all--".My code look like this but its not working.

<telerik:RadComboBox ID="market" Runat="server" Width="205px" DataSourceID="market_ds" DataTextField="Code" DataValueField="MainCodeID">  
<Items>   
<telerik:RadComboBoxItem runat="server" Text="-- all --" Value="all" Selected="true"/>   
</Items>   
</telerik:RadComboBox>   
 

 

 

 

 

 

Teoman
Top achievements
Rank 1
 answered on 29 Dec 2009
2 answers
131 views
I really like a lot of the RadGrid's functionality, and I think it's the route to go for the following problem, but i'm looking for some help on a best approach for the following problem.   Be it the rad grid or some other set of controls.

I have a Planning Year and a Planning Unit that are selectable controls, for the two controls, I want to populate some form of grid or other RadControl that allows me to repeat the following pattern.

Page 1
1. Print Planning Unit and associated year,
2. Print Planning Unit Purpose,
3. Print Planning Unit Objectives. (created by using planning unit and planning year, gives you the objective list for that planning year)

Page 2 thru end
3. Print Objective Data (created by getting planning unit and planning year, gives you the objective list for that planning year)
    a) Print Objective Statement
    b) Print Objective Tasks Detail (joined with objectives)
    c) Print Assessment Measures Detail (joined with objectives)
    d) Print Results Detail (joined with objectives)
    e) Print Use of Results Detail (joined with objectives)
    f) Status Reports Detail (joined with objectives.
Jeremy
Top achievements
Rank 2
 answered on 29 Dec 2009
2 answers
279 views
Hello,
I have a scenario where there are two grids where one is a master grid and one is a detail grid, similar to http://www.telerik.com/help/aspnet-ajax/grdrelatedgrids.html (except with two grids instead of three).  When a user selects a row from the master grid then data related to that row/item displays in the detail grid.  In my scenario, users add data to the detail grid and relate it to the master by manually entering the foreign key value (see the attached image and example below).

Example: There is a master grid that is populated with rows of "people".  A user selects a particular person then the detail grid displays the items that belong to the particular person.  The selected person ID is 3.  Users can add or update items that belong to the person by entering data into the detail grid, however currently they have to look at the master grid to tell what the ID is of the person.  ID is one of the datakeys in the detail grid.  It is a foreign key to the master grid data.  When someone needs to insert data into the detail grid related to the item they have selected in the master grid, I would like to pre-populate the textbox value when the editor for a new item is displayed.


I would like to use the datakey/primary key from the master grid to populate a value of a field when users are INSERTing new items into the detail grid.

Is this possible and how?
jgill
Top achievements
Rank 1
 answered on 29 Dec 2009
3 answers
219 views
Hi,
I have a grid with 3 detail tables on the same level. I need to disable the entire grid in such a way that the user will be able to open the lower tables to view the data but not change it (this needs to be done through code).
Would appreciate any help.
Thanks,
Lynda

<telerik:RadGrid ID="RadGridCV" runat="server" Skin="Office2007" GridLines="None" Width="98%" AllowMultiRowSelection="True" AllowMultiRowEdit="True">  
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Person_Id" Width="100%" EditMode="InPlace">  
    <Columns> 
        <telerik:GridBoundColumn DataField="Person_Id" SortExpression="Person_Id" ReadOnly="True" UniqueName="Person_Id" Visible="False"></telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Person_FirstNameEng" HeaderText="First Name" ReadOnly="True" SortExpression="Person_FirstNameEng" UniqueName="Person_FirstNameEng">  
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="Person_LastNameEng" HeaderText="Last Name" ReadOnly="True" SortExpression="Person_LastNameEng" UniqueName="Person_LastNameEng">  
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridBoundColumn> 
        <telerik:GridTemplateColumn UniqueName="ListOfPublicationsFile" HeaderText="List Of Publications File" DefaultInsertValue="">          
            <ItemTemplate>    
             <asp:Label ID="Label1" runat="server" Text='<%#Bind("ListOfPublicationsFile") %>'></asp:Label>    
            </ItemTemplate>   
            <EditItemTemplate><asp:FileUpload ID="FileUploadListOfPublications" runat="server" /></EditItemTemplate>    
            <ItemStyle VerticalAlign="Top" /> 
        </telerik:GridTemplateColumn>   
        <telerik:GridEditCommandColumn><ItemStyle ForeColor="Green" VerticalAlign="Top" /></telerik:GridEditCommandColumn> 
    </Columns> 
      
    <DetailTables> 
     <telerik:GridTableView Enabled="false" Name="AcademiclBackground" EditMode="InPlace" CommandItemDisplay="Bottom" runat="server" Caption="A. Academic Background" Width="100%" AutoGenerateColumns="False" DataKeyNames="ACBG_ItemNum">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="ACBG_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="ACBG_OrderBy" ColumnEditorID="myTextBoxEditor30px" HeaderText="Row No." SortExpression="ACBG_OrderBy" UniqueName="ACBG_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_FromTo" ColumnEditorID="myTextBoxEditor70px" HeaderText="Date From To" SortExpression="ACBG_FromTo" UniqueName="ACBG_FromTo">  
               <ItemStyle Width="80px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Institute" ColumnEditorID="myTextBoxEditor130px" HeaderText="Institute" SortExpression="ACBG_Institute" UniqueName="ACBG_Institute">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Degree" ColumnEditorID="myTextBoxEditor50px" HeaderText="Degree" SortExpression="ACBG_Degree" UniqueName="ACBG_Degree">  
               <ItemStyle Width="60px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="ACBG_Area" ColumnEditorID="myTextBoxEditor100px" HeaderText="Area" SortExpression="ACBG_Area" UniqueName="ACBG_Area">  
               <ItemStyle Width="120px" /> 
           </telerik:GridBoundColumn>   
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" 
               EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle  ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Academic Background Item" /> 
         <EditFormSettings><EditColumn UniqueName="EditCommandColumn1"></EditColumn></EditFormSettings>  
     </telerik:GridTableView> 
       
     <telerik:GridTableView Name="PreviousEmployment" EditMode="InPlace" CommandItemDisplay="Bottom" runat="server" Caption="B. Previous Employment&lt;br/&gt;&lt;span class=HeaderText&gt;Begin with present position (do not include tutoring, memberships in scientific associations or guest lectures)&lt;/span&gt;" Width="100%" AutoGenerateColumns="False" DataKeyNames="PE_ItemNum" AllowPaging="True">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="PE_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="PE_OrderBy" ColumnEditorID="myTextBoxEditor30px"  HeaderText="Row No." SortExpression="PE_OrderBy" UniqueName="PE_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_FromTo" ColumnEditorID="myTextBoxEditor70px" HeaderText="Date From To" SortExpression="PE_FromTo" UniqueName="PE_FromTo">  
               <ItemStyle Width="80px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Institute" ColumnEditorID="myTextBoxEditor130px" HeaderText="Institute" SortExpression="PE_Institute" UniqueName="PE_Institute">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Title" ColumnEditorID="myTextBoxEditor50px" HeaderText="Title" SortExpression="PE_Title" UniqueName="PE_Title">  
               <ItemStyle Width="60px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="PE_Area" ColumnEditorID="myTextBoxEditor100px" HeaderText="Research Area" SortExpression="PE_Area" UniqueName="PE_Area">  
               <ItemStyle Width="120px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Previous Employment Item" /> 
         <EditFormSettings> 
             <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
         </EditFormSettings> 
     </telerik:GridTableView> 
       
     <telerik:GridTableView Name="GrantsAndAwards" CommandItemDisplay="Bottom" runat="server" Caption="C. Grants and Awards Received Within the Past Five Years&lt;br/&gt;&lt;span class=HeaderText&gt;Please indicate the date of receiving the grant/award and the funding period in the comments box.&lt;/span&gt;" Width="100%" AutoGenerateColumns="False" DataKeyNames="GAA_Id" AllowPaging="True">  
       <ParentTableRelation> 
         <telerik:GridRelationFields   
           DetailKeyField="GAA_PersonId" 
           MasterKeyField="Person_Id" /> 
       </ParentTableRelation> 
       <Columns> 
           <telerik:GridBoundColumn DataField="GAA_OrderBy"  HeaderText="Row No." SortExpression="GAA_OrderBy" UniqueName="GAA_OrderBy">  
               <ItemStyle Width="30px" /> 
           </telerik:GridBoundColumn>   
           <telerik:GridBoundColumn DataField="GAA_ResearchTopics"  HeaderText="Research Topics" SortExpression="GAA_ResearchTopics" UniqueName="GAA_ResearchTopics">  
               <ItemStyle Width="200px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="GAA_FundingAgency" HeaderText="Funding Organization" SortExpression="GAA_FundingAgency" UniqueName="GAA_FundingAgency">  
               <ItemStyle Width="150px" /> 
           </telerik:GridBoundColumn> 
           <telerik:GridBoundColumn DataField="GAA_TotalGrant" HeaderText="Total (in $)" SortExpression="GAA_TotalGrant" UniqueName="GAA_TotalGrant">  
               <HeaderStyle Wrap="False" /> 
               <ItemStyle Wrap="False" Width="60px" /> 
           </telerik:GridBoundColumn>    
           <telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/cancel.gif" EditImageUrl="~/Images/edit.gif" InsertImageUrl="~/Images/update.gif" UpdateImageUrl="~/Images/update.gif"><ItemStyle ForeColor="#007E00" /></telerik:GridEditCommandColumn> 
           <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" ButtonType="ImageButton" ImageUrl="~/Images/delete.gif"><ItemStyle ForeColor="#E40000" /></telerik:GridButtonColumn> 
       </Columns> 
       <CommandItemSettings AddNewRecordText="Add Grant and Award Item" /> 
        <EditFormSettings UserControlName="~/Controls/ucGrantsAndAwardsDetails.ascx" EditFormType="WebUserControl"><EditColumn UniqueName="EditCommandColumn1"></EditColumn></EditFormSettings>  
     </telerik:GridTableView> 
 
</DetailTables> 
    <ExpandCollapseColumn Visible="True"></ExpandCollapseColumn> 
    <EditFormSettings> 
        <EditColumn UniqueName="EditCommandColumn1">  
        </EditColumn> 
    </EditFormSettings> 
</MasterTableView> 
</telerik:RadGrid> 
Daniel
Telerik team
 answered on 29 Dec 2009
12 answers
158 views

Hi,
I have created a grid at runtime and have set properties as follows:

 

 

MainGrid.ClientSettings.AllowKeyboardNavigation = true;   
   
MainGrid.ClientSettings.Selecting.AllowRowSelect = true;   
   
MainGrid.ClientSettings.ClientEvents.OnRowSelected = "OnRowSelected";  
 
<script type="text/javascript" language="javascript">   
   
function OnRowSelected(sender, args)   
{  
//My code  
}   
</script> 
 
 

 

 

this code works perfectly fine when i use 'SPACE' key for selecttion
I dont want 'ENTER' key to get into Edit mode instead what i want is to use 'ENTER' key for selection
What this means is,whatever currently happening using 'SPACE' bar it should happen on pressing 'ENTER' key

Regards,
Mangesh

Tsvetoslav
Telerik team
 answered on 29 Dec 2009
1 answer
128 views
I'm facing the exact same problem of the item and page count in the footer not updating after I change the data source in the

NeedDataSource event handler.

Other people have run into this issue:

http://www.telerik.com/community/forums/aspnet-ajax/grid/page-count-inaccurate-after-new-search.aspx#0

http://www.telerik.com/community/forums/aspnet-ajax/grid/rebind-not-updating-pager.aspx

However, the suggestion of setting EnableLinqExpressions to false did not work for me. Does anyone have any other suggestions to try? I'm running on .NET 3.5 and using RadControls for ASP.NET AJAX Q3 2009 NET3.5.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SearchPersonControl.ascx.cs" Inherits="SearchPersonControl" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" namespace="System.Web.UI.WebControls" tagprefix="asp" %>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

<asp:Table ID="tblMainLayout" runat="server">
    <asp:TableRow>
        <asp:TableCell>
            <asp:Label ID="lblPerson" runat="server" Text="Persoon:"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <telerik:RadTextBox ID="txtPersonSearch" Runat="server" Width="200px"></telerik:RadTextBox>
        </asp:TableCell>
        <asp:TableCell>
            <asp:Button ID="btnSearch" runat="server" onclick="btnSearch_Click" Text="Search" />
        </asp:TableCell>
        <asp:TableCell>
            <asp:Button ID="btnAdvancedSearch" runat="server" onclick="btnAdvancedSearch_Click" Text="Show Advanced Search" />
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow ID="tblrAdvancedSearch1" runat="server" Visible="false">
        <asp:TableCell>
            <asp:Label ID="lblID" runat="server" Text="ID nummer: "></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <telerik:RadTextBox ID="txtID" Runat="server"></telerik:RadTextBox>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow ID="tblrAdvancedSearch2" runat="server" Visible="false">
        <asp:TableCell>
            <asp:Label ID="lblName" runat="server" Text="Naam:"></asp:Label>
        </asp:TableCell>
        <asp:TableCell>
            <telerik:RadTextBox ID="txtName" Runat="server" Width="200px"></telerik:RadTextBox>
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell ColumnSpan="4">
            <telerik:RadGrid ID="grdPersons" runat="server" AllowPaging="True"
                DataSourceID="HECINA_DEV_M_SearchPersonEntities" GridLines="None"
                AllowSorting="True" AllowFilteringByColumn = "true" OnNeedDataSource="grdPersons_NeedDataSource"
                EnableLinqExpressions="false">
                <MasterTableView AutoGenerateColumns="False"
                        DataSourceID="HECINA_DEV_M_SearchPersonEntities">
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <SortExpressions>
                        <telerik:GridSortExpression FieldName="Persons_FullName" SortOrder="Ascending" />
                    </SortExpressions>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridBoundColumn DataField="Persons_FullName" DefaultInsertValue=""
                            HeaderText="Naam" ReadOnly="True" SortExpression="Persons_FullName"
                            UniqueName="Persons_FullName"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Persons_BirthDate"
                            DataType="System.DateTime" DefaultInsertValue="" HeaderText="Geboortedatum"
                            ReadOnly="True" SortExpression="Persons_BirthDate"
                            UniqueName="Persons_BirthDate"></telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Persons_IdentificationNumber"
                            DefaultInsertValue="" HeaderText="Identificatienummer" ReadOnly="True"
                            SortExpression="Persons_IdentificationNumber"
                            UniqueName="Persons_IdentificationNumber"></telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>
<asp:EntityDataSource ID="HECINA_DEV_M_SearchPersonEntities" runat="server"
    ConnectionString="name=HECINA_DEV_M_SearchPersonEntities"
    DefaultContainerName="HECINA_DEV_M_SearchPersonEntities"
    EntitySetName="Persons" EntityTypeFilter="Persons"
    Select="it.[Persons_BirthDate], it.[Persons_FullName], it.[Persons_IdentificationNumber]">
</asp:EntityDataSource>

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CX.Hecina.DataAccessLayer;

public partial class SearchPersonControl : System.Web.UI.UserControl
{
    HECINA_DEV_M_SearchPersonEntities searchPersonEntities;

    protected void Page_Load(object sender, EventArgs e)
    {
        this.searchPersonEntities = new HECINA_DEV_M_SearchPersonEntities();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //Only one of these can be set. Always clear both to ensure the data grid is current.
        this.grdPersons.DataSourceID = null;
        this.grdPersons.DataSource = null;
        this.grdPersons.CurrentPageIndex = 0;
        this.grdPersons.Rebind();
    }

    protected void grdPersons_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        //Always default to the full data set. This is useful if no search terms were specified.
        IQueryable<Persons> qry = this.searchPersonEntities.Persons.OrderBy(p => p.Persons_FullName);

        if (this.txtName.Text.Length != 0)
        {
            qry = this.searchPersonEntities.Persons.Where(p => p.Persons_FullName.ToUpper().Contains(this.txtName.Text.ToUpper()));
        }

        if (this.txtID.Text.Length != 0)
        {
            qry = this.searchPersonEntities.Persons.Where(p => p.Persons_IdentificationNumber.ToUpper().Contains(this.txtID.Text.ToUpper()));
        }

        //Google-like search that matches on multiple fields simultaneously.
        if (this.txtPersonSearch.Text.Length != 0)
        {
            string searchText = this.txtPersonSearch.Text.ToUpper();
            qry = this.searchPersonEntities.Persons.Where(p => p.Persons_FullName.ToUpper().Contains(searchText) ||
                //TODO: Figure this out, at runtime an exception is thrown that LINQ does not
                //recognize ToShortDateString().
                //p.Persons_BirthDate.ToShortDateString().Contains(searchText) ||
                p.Persons_IdentificationNumber.ToUpper().Contains(searchText));
        }

        //TODO: figure out how to update record and page count.
        this.grdPersons.DataSource = qry;
    }

    protected void btnAdvancedSearch_Click(object sender, EventArgs e)
    {
        //Simply invert the visibility property value of the advanced search fields.
        this.tblrAdvancedSearch1.Visible ^= true;
        this.tblrAdvancedSearch2.Visible ^= true;

        if (this.tblrAdvancedSearch1.Visible == true)
        {
            this.btnAdvancedSearch.Text = "Hide Advanced Search";
        }
        else
        {
            this.btnAdvancedSearch.Text = "Show Advanced Search";
        }
    }
}

The only thing I could think I'm doing differently is that I'm using the grid inside a user control.

Tsvetoslav
Telerik team
 answered on 29 Dec 2009
7 answers
132 views
Hi,

In one of my user control, I've a radgrid with paging turned on. when i travel to the 3rd or 4th page or any page, then open up my ser control, my last page which i was working on is appearing as the current page. But I want the first page to alwasy come whenever I open up my user control and bind the grid.

Pls help me with code samples.

To be more clear, I do not have a "Add new record " button. It's my own button"Add" which opens up  a user control with a grid(with paging on).
When I'm in my user control, I go to the 3rd page and click cancel and exit from the user control and if I click "ADD" button from my aspx ,I open up the user control. but the grid is in page 3 and not in page 1. How do I make the grid to be in page 1 always when I open up that user control. Pls do help:
Tsvetoslav
Telerik team
 answered on 29 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?