LinqDataSource in Telerik:grid

2 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 12 Jun 2008 Link to this post

    hi,
    In my application i am using linqdatasource to show records in grid.
    I have two linqdatasources. one on main grid and other on its detail table's GridTableView.
    Problem is that first linqdatasource is working properly but second its not coimng on second linq's.

    I am giving my code below..

    ...............aspx..................

    <%

    @ Page Language="C#" MasterPageFile="~/MasterPages/Default.Master" AutoEventWireup="true"

    CodeFile="Default.aspx.cs" EnableEventValidation="false" Inherits="Pages_Examinations_Default" Title="Untitled Page" %>

    <%

    @ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

    <%

    @ MasterType VirtualPath="~/MasterPages/Default.Master" %>

    <

    asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">

    function refreshGrid(navigate)

    {

    if(!navigate)

    grid.AjaxRequest(

    '<%= grdExams.UniqueID %>', 'Rebind');

    else

    grid.AjaxRequest(

    '<%= grdExams.UniqueID %>', 'RebindAndNavigate');

    }

    var grid;

    function gridCreated() {grid = this;}

    </script>

    <asp:LinqDataSource ID="LinqDataSource1" runat="server"

    OnSelecting="LinqDataSource1_Selecting">

    </asp:LinqDataSource>

    <asp:LinqDataSource ID="LinqDataSource2" runat="server"

    onselecting="LinqDataSource2_Selecting">

    </asp:LinqDataSource>

    <telerik:RadGrid ID="grdExams" runat="server" DataSourceID="LinqDataSource1"

    AllowFilteringByColumn="True" AllowSorting="True"

    AutoGenerateColumns="False" AllowPaging="True" EnableViewState="false"

    Skin="Office2007" OnItemDataBound="grdExams_ItemDataBound"

    GridLines="None" AllowAutomaticDeletes="True"

    OnItemCommand="grdExams_ItemCommand" OnPreRender="grdExams_PreRender"

    GroupingEnabled="False" ondatabound="grdExams_DataBound"

    ondetailtabledatabind="grdExams_DetailTableDataBind">

    <ClientSettings AllowDragToGroup="True" AllowExpandCollapse="true" AllowKeyboardNavigation="True">

    <Selecting AllowRowSelect="True" />

    <ClientEvents OnGridCreated="gridCreated" />

    </ClientSettings>

    <GroupPanel Visible="True">

    </GroupPanel>

    <MasterTableView GridLines="None" DataKeyNames="ID" DataSourceID="LinqDataSource1"

    CommandItemDisplay="TopAndBottom" Width="100%" Name="Examinations">

    <DetailTables>

    <telerik:GridTableView HierarchyLoadMode="Client" DataSourceID="LinqDataSource2" DataKeyNames="ID"

    Width="100%" runat="server" EnableViewState="false" CommandItemDisplay="Bottom" AllowAutomaticDeletes="true"

    AllowFilteringByColumn="false" Name="Detractions">

    <ParentTableRelation>

    <telerik:GridRelationFields MasterKeyField="ID" DetailKeyField="ExaminationID" />

    </ParentTableRelation>

    <EditFormSettings>

    <PopUpSettings ScrollBars="None"></PopUpSettings>

    </EditFormSettings>

    <CommandItemTemplate>

    <div style="width: 100%; text-align: center">

    <div style="float: left; padding: 5px; padding-left: 10px">

    <asp:LinkButton ID="lnkAddDetraction" runat="server" CommandName="InitInsert" >

    <asp:Image ID="imgAddDetraction" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/RadControls/Grid/Skins/Office2007/AddRecord.gif"

    AlternateText="Add a new Detraction to the current record." />

    <asp:Label ID="lblAddRecord" runat="server" Style="text-decoration: none;" Text=" Add Detraction...">

    </asp:Label>

    </asp:LinkButton>

    </div>

    <div style="float: right; padding: 5px; padding-right: 10px">

    <asp:LinkButton ID="lnkRefreshDetraction" runat="server" CommandName="RefreshDetractions">

    <asp:Image ID="imgRefreshDetraction" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/RadControls/Grid/Skins/Office2007/Refresh.gif"

    AlternateText="Add Detractopm Record" />

    <asp:Label ID="lblRefreshDetraction" runat="server" Style="text-decoration: none;"

    Text=" Refresh Detraction List"></asp:Label>

    </asp:LinkButton>

    </div>

    </div>

    </CommandItemTemplate>

    <RowIndicatorColumn Visible="False">

    <HeaderStyle Width="20px"></HeaderStyle>

    </RowIndicatorColumn>

    <ExpandCollapseColumn Visible="False" Resizable="False">

    <HeaderStyle Width="20px"></HeaderStyle>

    </ExpandCollapseColumn>

    <Columns>

    <telerik:GridTemplateColumn UniqueName="TemplateDetractionEditColumn" AllowFiltering="false"

    ShowSortIcon="false">

    <ItemTemplate>

    <asp:ImageButton ID="cmdDelete" runat="server" CommandName="Delete" OnClientClick="return confirm('Are you sure?');"

    ImageUrl="~/RadControls/Grid/Skins/Office2007/Delete.gif" />

    <asp:ImageButton ID="cmdEdit" runat="server" CommandName="Edit" ImageUrl="~/RadControls/Grid/Skins/Office2007/Edit.gif" />

    </ItemTemplate>

    </telerik:GridTemplateColumn>

    <telerik:GridBoundColumn DataField="Severity" HeaderText="Severity" SortExpression="Severity"

    UniqueName="Severity">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="DetractionType" HeaderText="Type" SortExpression="DetractionType"

    UniqueName="DetractionType">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="DetractionSource" HeaderText="Source" ReadOnly="True"

    SortExpression="DetractionSource" UniqueName="DetractionSource">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="TechnologistFault" DataType="System.Decimal" HeaderText="Technologist"

    SortExpression="TechnologistFault" UniqueName="TechnologistFault">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="EquipmentFault" DataType="System.Decimal" HeaderText="Equipment"

    SortExpression="EquipmentFault" UniqueName="EquipmentFault">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="PatientFault" DataType="System.Decimal" HeaderText="Patient"

    SortExpression="PatientFault" UniqueName="PatientFault">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="ProcessFault" DataType="System.Decimal" HeaderText="Process"

    SortExpression="ProcessFault" UniqueName="ProcessFault">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn Visible="false" DataField="DV" DataType="System.Decimal" HeaderText="DV"

    SortExpression="DV" UniqueName="DV">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="ID" Visible="false" DataType="System.Int32" HeaderText="ID"

    ReadOnly="True" SortExpression="ID" UniqueName="DetractionID">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn Visible="false" DataField="ExaminationID" DataType="System.Int32"

    HeaderText="ExaminationID" SortExpression="ExaminationID" UniqueName="ExaminationID">

    </telerik:GridBoundColumn>

    </Columns>

    </telerik:GridTableView>

    </DetailTables>

    <RowIndicatorColumn Visible="False">

    <HeaderStyle Width="20px"></HeaderStyle>

    </RowIndicatorColumn>

    <ExpandCollapseColumn Visible="True" Resizable="False">

    <HeaderStyle Width="20px"></HeaderStyle>

    </ExpandCollapseColumn>

    <CommandItemTemplate>

    <div style="width: 100%; text-align: center">

    <div style="float:left; padding:5px; padding-left:10px">

    <asp:LinkButton ID="lnkAddRecord" runat="server" CommandName="InitInsert">

    <div style="float:left; padding-left:5px">

    <asp:Image ID="imgAddRecord" runat="server" ImageAlign="Top" ImageUrl="~/Images/Icons/24/ExamAdd.png"

    AlternateText="Add an Examination record" /></div>

    <div style="float: left; padding-left: 5px; text-align: left; text-decoration: none;">

    <asp:Label ID="lblAddRecord" runat="server" Text="Add<br />Examination..."></asp:Label></div>

    </asp:LinkButton>

    </div>

    <div style="float: left; padding: 5px; padding-left: 10px">

    <asp:LinkButton ID="lnkImportExams" runat="server" CommandName="ImportExams">

    <div style="float: left; padding-left: 5px">

    <asp:Image ID="imgImportExams" runat="server" ImageAlign="Top" ImageUrl="~/Images/Icons/24/Examimport.png"

    AlternateText="Import Examination records" /></div>

    <div style="float: left; padding-left: 5px; text-align: left; text-decoration: none;">

    <asp:Label ID="lblImportExams" runat="server" Text="Import<br />Examination Records...">

    </asp:Label></div>

    </asp:LinkButton>

    </div>

    <div style="float: right; padding: 5px; padding-right: 10px">

    <asp:LinkButton ID="lnkRefresh" runat="server" CommandName="RefreshExams">

    <div style="float: left; padding-left: 5px">

    <asp:Image ID="imgRefresh" runat="server" ImageAlign="Top" ImageUrl="~/Images/Icons/24/ExamRefresh.png"

    AlternateText="Refresh current list of Examinations" /></div>

    <div style="float: left; padding-left: 5px; text-align: left; text-decoration: none;">

    <asp:Label ID="lblRefresh" runat="server" Text=" Refresh<br />Examination List"></asp:Label></div>

    </asp:LinkButton>

    </div>

    </div>

    </CommandItemTemplate>

    <Columns>

    <telerik:GridBoundColumn DataField="ID" DataType="System.Int32"

    HeaderText="ID" SortExpression="ID" UniqueName="ID" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="ExaminationDate" HeaderText="ExaminationDate"

    SortExpression="ExaminationDate" UniqueName="ExaminationDate"

    DataType="System.DateTime" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="ExaminationType"

    HeaderText="ExaminationType" SortExpression="ExaminationType"

    UniqueName="ExaminationType" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="AccessionCode" HeaderText="AccessionCode"

    SortExpression="AccessionCode" UniqueName="AccessionCode" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="Modality" HeaderText="Modality" SortExpression="Modality"

    UniqueName="Modality" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn DataField="Facility" HeaderText="Facility" SortExpression="Facility"

    UniqueName="Facility" ReadOnly="True">

    </telerik:GridBoundColumn>

    <telerik:GridBoundColumn

    DataField="Technologist" HeaderText="Technologist" ReadOnly="True"

    SortExpression="Technologist" UniqueName="Technologist">

    </telerik:GridBoundColumn>

    </Columns>

    <

    EditFormSettings>

    <

    PopUpSettings ScrollBars="None"></PopUpSettings>

    </

    EditFormSettings>

    <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>

    </MasterTableView>

    <ExportSettings>

    <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in"

    PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" />

    </ExportSettings>

    </telerik:RadGrid>

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleStatusbar="True"

    Skin="Vista" Behavior="Move,Close,Resize,Reload" Modal="True" ReloadOnShow="True"

    SingleNonMinimizedWindow="True">

    <Windows>

    <telerik:RadWindow ID="ExamDialog" runat="server" Width="600" Height="525" />

    <telerik:RadWindow ID="DetractionDialog" runat="server" Width="700" Height="560" />

    <telerik:RadWindow ID="UploadDialog" runat="server" Width="450" Height="280" Behavior="Close" />

    <telerik:RadWindow

    Width="610px"

    Height="540px"

    Runat="server"

    Id="Radwindow1"

    VisibleStatusbar="false" >

    </telerik:RadWindow>

    </Windows>

    </telerik:RadWindowManager>

    </

    asp:Content>

    ............................cs...........................

    using

    System;

    using

    System.Data;

    using

    System.Text;

    using

    System.Web.UI;

    using

    System.Web.UI.HtmlControls;

    using

    System.Web.UI.WebControls;

    using

    Telerik.Web.UI;

    using

    System.Collections;

    using

    System.Linq;

    using

    System.Collections.Generic;

    public

    partial class Pages_Examinations_Default : QMSPage

    {

    private Hashtable _ordersExpandedState;

    private Hashtable _selectedState;

    int ModalityID;

    private string currentFilter

    {

    get

    {

    StringBuilder sb = new StringBuilder();

    string temp = string.Empty;

    //sb.Append(this.Master.GetModalityFilter("ExaminationType.ModalityID"));

    if (Session["ModalityTit"] != null)

    {

    //sb.Append(Session["ModalityTit"].ToString());

    sb.Append(

    "Modality.ID = 1");

    }

    //temp = this.Master.GetDetractionFilter("Detraction.DetractionTypeID");

    if (Session["DetractionTypeCount"] != null)

    {

    //temp = Session["DetractionTypeCount"].ToString();

    }

    if (temp.Length > 0)

    {

    if (sb.Length > 0) sb.Append(" AND ");

    sb.Append(temp);

    }

    temp =

    this.Master.GetExamDateFilter("Examination.ExaminationDate");

    //temp = Session[""].ToString();

    if (temp.Length > 0)

    {

    if (sb.Length > 0) sb.Append(" AND ");

    sb.Append(temp);

    }

    temp =

    this.Master.GetExamTypeFilter("Examination.ExaminationTypeID");

    if (temp.Length > 0)

    {

    if (sb.Length > 0) sb.Append(" AND ");

    sb.Append(temp);

    }

    return sb.ToString();

    }

    }

    protected override void OnInit(EventArgs e)

    {

    base.OnInit(e);

    Master.FilterChanged +=

    new EventHandler(GlobalFilter_FilterChanged);

    }

    protected void GlobalFilter_FilterChanged(object sender, EventArgs e)

    {

    Session[

    "ExaminationsDefault_currentFilter"] = currentFilter;

    }

    protected void Page_Load(object sender, EventArgs e)

    {

    try

    {

    //Session["ExaminationsDefault_currentFilter"] = currentFilter;

    //string mod = Session["ModalityCount"].ToString();

    //string strOriginalString = mod;

    //string[] strSplittedString = mod.Split(',');

    //for (int nums = 0; nums < strSplittedString.Length; nums++)

    //{

    // ModalityID = Convert.ToInt16(strSplittedString[nums]);

    //}

    //ModalityID = Convert.ToInt16(Session["ModalityCount"]);

    LinqDataSource1.DataBind();

    }

    catch (Exception ex)

    {

    Response.Write(

    "Examination Page_PageLoad:" + ex.ToString());

    }

    if (!IsPostBack)

    {

    //reset expanded states

    this._ordersExpandedState = null;

    this.Session["_ordersExpandedState"] = null;

    }

    }

    //Save/load expanded states Hash from the session

    //this can also be implemented in the ViewState

    private Hashtable ExpandedStates

    {

    get

    {

    if (this._ordersExpandedState == null)

    {

    _ordersExpandedState =

    this.Session["_ordersExpandedState"] as Hashtable;

    if (_ordersExpandedState == null)

    {

    _ordersExpandedState =

    new Hashtable();

    this.Session["_ordersExpandedState"] = _ordersExpandedState;

    }

    }

    return this._ordersExpandedState;

    }

    }

    //Clear the state for all expanded children if a parent item is collapsed

    private void ClearExpandedChildren(string parentHierarchicalIndex)

    {

    string[] indexes = new string[this.ExpandedStates.Keys.Count];

    this.ExpandedStates.Keys.CopyTo(indexes, 0);

    foreach (string index in indexes)

    {

    //all indexes of child items

    if (index.StartsWith(parentHierarchicalIndex + "_") ||

    index.StartsWith(parentHierarchicalIndex +

    ":"))

    {

    this.ExpandedStates.Remove(index);

    }

    }

    }

    //Save/load selected states Hash from the session

    //this can also be implemented in the ViewState

    private Hashtable SelectedStates

    {

    get

    {

    if (this._selectedState == null)

    {

    _selectedState =

    this.Session["_selectedState"] as Hashtable;

    if (_selectedState == null)

    {

    _selectedState =

    new Hashtable();

    this.Session["_selectedState"] = _selectedState;

    }

    }

    return this._selectedState;

    }

    }

    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)

    {

    base.RaisePostBackEvent(sourceControl, eventArgument);

    if (sourceControl is RadGrid)

    {

    grdExams.MasterTableView.DetailTables[0].Rebind();

    grdExams.MasterTableView.Rebind();

    }

    }

    private void editRecord(GridCommandEventArgs e)

    {

    // Determine the path to the record editor

    string args = string.Empty;

    if (e.Item.OwnerTableView.Name == "Examinations")

    args =

    string.Format(

    "\"Edit.aspx?id={0}\", \"ExamDialog\"",

    e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][

    "ID"].ToString());

    else

    args =

    string.Format(

    "\"Detractions/Edit.aspx?id={0}\", \"DetractionDialog\"",

    e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][

    "ID"].ToString());

    openRadWindow(args);

    }

    private void openRadWindow(string args)

    {

    }

    protected void grdExams_PreRender(object sender, EventArgs e)

    {

    if (SelectedStates.Count == 0 && grdExams.Items.Count > 0)

    {

    grdExams.Items[0].Selected =

    true;

    this.SelectedStates[grdExams.Items[0].ItemIndexHierarchical] = true;

    }

    else

    toggleExpandedStates();

    }

    protected void grdExams_DataBound(object sender, EventArgs e)

    {

    }

    private void toggleExpandedStates()

    {

    if (grdExams.Items.Count == 0)

    {

    this.ExpandedStates.Clear();

    this.SelectedStates.Clear();

    return;

    }

    ////Expand all items using our custom storage

    string[] indexes = new string[this.ExpandedStates.Keys.Count];

    this.ExpandedStates.Keys.CopyTo(indexes, 0);

    ArrayList arr = new ArrayList(indexes);

    //Sort so we can guarantee that a parent item is expanded before any of

    //its children

    arr.Sort();

    foreach (string key in arr)

    {

    bool value = (bool)this.ExpandedStates[key];

    if (value)

    {

    //grdExams.Items[key].Expanded = true;

    //grdExams.MasterTableView.DetailTables[0].Rebind();

    }

    }

     

    //Select all items using our custom storage

    indexes =

    new string[this.SelectedStates.Keys.Count];

    this.SelectedStates.Keys.CopyTo(indexes, 0);

    arr =

    new ArrayList(indexes);

    //Sort to ensure that a parent item is selected before any of its children

    arr.Sort();

    foreach (string key in arr)

    {

    bool value = (bool)this.SelectedStates[key];

    if (value)

    {

    grdExams.Items[key].Selected =

    true;

    }

    }

    }

    protected void grdExams_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

    {

    if ((e.Item is GridCommandItem) && (e.Item.OwnerTableView.Name == "Detractions"))

    {

    GridCommandItem cmditm = (GridCommandItem)e.Item;

    LinkButton lnkbtn = (LinkButton)cmditm.FindControl("lnkAddDetraction");

    lnkbtn.OnClientClick =

    "window.radopen('Detractions/Edit.aspx','DetractionDialog');return false;";

    }

    }

    protected void grdExams_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)

    {

    switch (e.CommandName)

    {

    case RadGrid.ExpandCollapseCommandName:

    //Is the item about to be expanded or collapsed

    if (!e.Item.Expanded)

    {

    //Save its unique index among all the items in the hierarchy

    this.ExpandedStates[e.Item.ItemIndexHierarchical] = true;

    }

    else //collapsed

    {

    this.ExpandedStates.Remove(e.Item.ItemIndexHierarchical);

    this.ClearExpandedChildren(e.Item.ItemIndexHierarchical);

    }

    e.Item.Selected =

    true;

    break;

    case RadGrid.PageCommandName:

    this.ExpandedStates.Clear();

    this.SelectedStates.Clear();

    break;

    case RadGrid.EditCommandName:

    //Save its unique index among all the items in the hierarchy

    this.SelectedStates.Clear();

    if (e.Item.OwnerTableView.Name == "Detractions")

    //Save its unique index among all the items in the hierarchy

    this.SelectedStates[e.Item.OwnerTableView.ParentItem.ItemIndexHierarchical] = true;

    else

    //Save its unique index among all the items in the hierarchy

    this.SelectedStates[e.Item.ItemIndexHierarchical] = true;

    editRecord(e);

    e.Canceled =

    true;

    break;

    case RadGrid.InitInsertCommandName:

    this.SelectedStates.Clear();

    if (e.Item.OwnerTableView.Name == "Detractions")

    //Save its unique index among all the items in the hierarchy

    this.SelectedStates[e.Item.OwnerTableView.ParentItem.ItemIndexHierarchical] = true;

    else

    //Save its unique index among all the items in the hierarchy

    this.SelectedStates[e.Item.ItemIndexHierarchical] = true;

    insertRecord(e);

    e.Canceled =

    true;

    break;

    case RadGrid.DeleteCommandName:

    if (e.Item.OwnerTableView.Name == "Examinations")

    this.SelectedStates.Clear();

    DataBind();

    break;

    case "RefreshExams":

    grdExams.MasterTableView.Rebind();

    break;

    case "RefreshDetractions":

    grdExams.MasterTableView.DetailTables[0].Rebind();

     

    break;

    case "ImportExams":

    openRadWindow(

    "\"Import.aspx\", \"UploadDialog\"");

     

    break;

    }

    }

    protected void grdExams_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)

    {

    GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

    }

    private void insertRecord(GridCommandEventArgs e)

    {

    string args = string.Empty;

    GridDataItem parentExam = e.Item.OwnerTableView.ParentItem;

    // Get the Exam Id

    if (e.Item.OwnerTableView.Name == "Detractions")

    {

    args =

    string.Format("\"Detractions/Edit.aspx?eid={0}\", \"DetractionDialog\"",

    parentExam.OwnerTableView.DataKeyValues[parentExam.ItemIndex][

    "ID"].ToString());

    }

    else

    {

    args =

    "\"Edit.aspx\", \"ExamDialog\"";

    }

    ((

    LinkButton)(e.CommandSource)).OnClientClick = "javascript:alert('hi');return false;";

    }

    protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)

    {

    try

    {

    int[] Modalityids = {0};

    int[] ExamTypeids = {0};

    int[] Locationids = {0};

    int[] Technologistids = {0};

    string ExamDate = string.Empty;

    string ToExamDate = string.Empty;

    DateTime FromExamDateid;

    DateTime ToExamDateid;

    string FromDayShift = string.Empty;

    string ToDayShift = string.Empty;

    DateTime FromDayShiftid;

    DateTime ToDayShiftid;

    List<int> ModalityList = new List<int>();

    List<int> ExamTypeList = new List<int>();

    List<int> LocationList = new List<int>();

    List<int> TechnologistList = new List<int>();

    if (Session["ModalityCount"] != null)

    {

    foreach (string number in Session["ModalityCount"].ToString().Split(','))

    {

    ModalityList.Add(

    Int32.Parse(number));

    }

    Modalityids = ModalityList.ToArray();

    }

    if (Session["ExamTypeCount"] != null)

    {

    foreach (string number in Session["ExamTypeCount"].ToString().Split(','))

    {

    ExamTypeList.Add(

    Int32.Parse(number));

    }

    ExamTypeids = ExamTypeList.ToArray();

    }

    if (Session["LocationCount"] != null)

    {

    foreach (string number in Session["LocationCount"].ToString().Split(','))

    {

    LocationList.Add(

    Int32.Parse(number));

    }

    Locationids = LocationList.ToArray();

    }

    if (Session["PerTechnologistCount"] != null)

    {

    foreach (string number in Session["PerTechnologistCount"].ToString().Split(','))

    {

    TechnologistList.Add(

    Int32.Parse(number));

    }

    Technologistids = TechnologistList.ToArray();

    }

    if (Session["FromExamDate"] != null)

    {

    //ExamDateList.Add(Int32.Parse(Session["FromExamDate"].ToString()));

    //ExamDateList.ToArray();

    ExamDate = Session[

    "FromExamDate"].ToString();

    //if(Session["FromDayShift"]!= null)

    //{

    // ExamDate = Session["FromExamDate"].ToString() + Session["FromDayShift"].ToString();

    //}

    FromExamDateid =

    DateTime.Parse(ExamDate);

    }

    else

    {

    string date = "1900-01-01 00:00:00.000";

    //ExamDateList.Add(Int32.Parse(date));

    ExamDate = date;

    //ExamDateList.ToArray();

    FromExamDateid =

    Convert.ToDateTime(ExamDate);

    }

    if (Session["ToExamDate"] != null)

    {

    ToExamDate = Session[

    "ToExamDate"].ToString();

    ToExamDateid =

    DateTime.Parse(ToExamDate);

    }

    else

    {

    string date = "3020-01-01 00:00:00.000";

    ToExamDate = date;

    ToExamDateid =

    Convert.ToDateTime(ToExamDate);

    }

    if (Session["FromDayShift"] != null)

    {

    FromDayShift =

    "01/01/1900" + Session["FromDayShift"].ToString();

    FromDayShiftid =

    DateTime.Parse(FromDayShift);

    }

    else

    {

    string time = "1900-01-01 00:00:00.000";

    FromDayShift = time;

    FromDayShiftid =

    Convert.ToDateTime(FromDayShift);

    }

    if (Session["ToDayShift"] != null)

    {

    ToDayShift =

    "01/01/1900" + Session["ToDayShift"].ToString();

    ToDayShiftid =

    DateTime.Parse(ToDayShift);

    }

    else

    {

    string time = "3020-01-01 00:00:00.000";

    ToDayShift = time;

    ToDayShiftid =

    Convert.ToDateTime(ToDayShift);

    }

    QMSDataContext exampleContext = new QMSDataContext();

    e.Result =

    from p in exampleContext.vw_Examinations

    where p.AccountID == Convert.ToInt16(Session["AccountID"])

    && ((!Modalityids.Contains(0) && Modalityids.Contains(p.ModalityID)) || Modalityids.Contains(0))

    && ((!ExamTypeids.Contains(0) && ExamTypeids.Contains(p.ExaminationTypeID)) || ExamTypeids.Contains(0))

    && ((!Locationids.Contains(0) && Locationids.Contains(p.LocationID)) || Locationids.Contains(0))

    && ((!Technologistids.Contains(0) && Technologistids.Contains(p.TechnologistID )) || Technologistids.Contains(0))

    && ((p.DateOnly >= FromExamDateid) && (p.DateOnly <= ToExamDateid))

    && ((p.TimeOnly >= FromDayShiftid) && (p.TimeOnly <= ToDayShiftid))

    select new { p.ID, p.ExaminationDate, p.ExaminationType, p.AccessionCode, p.Modality, p.Facility, p.Technologist };

    }

    catch (Exception ex)

    {

    }

    }

    protected void LinqDataSource2_Selecting(object sender, LinqDataSourceSelectEventArgs e)   /////////Its not coimng here on every post back..

    {

    QMSDataContext dsDetraction = new QMSDataContext();

    //e.Result = from d in dsDetraction.vw_Detractions

    // where d.ID ==

    }

    }

    Please help me.
    Thanks

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 16 Jun 2008 Link to this post

    Hello Rahul,

    Based on the supplied information, it's hard to determine the cause of the issue, although I suspect it is a databinding problem. In order to further investigate the issue, it will be best if you open a formal support ticket, and send us a small working project, which we can debug locally. As soon as we do, we will advise you further.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top