RSS

Category Archives: Silverlight

Resolve : Issue in reading CVS file in Silverlight


Hi,
While reading CSV file, in each line first character is missing from the file.the solution of this problem below

 

PhoneNumber  ClientName	Status
334455	     sajjad ahmed Closed

Problem:
every record missing phonenumber first digit miss

Befor Solution:

                    StreamReader lObjStreamReader = new StreamReader(dlgOpen.File.OpenRead());

                    while (( lObjStreamReader.ReadLine()) != null)
                    {
                         string= lObjStreamReader.ReadLine();

After Solution:

 StreamReader lObjStreamReader = new StreamReader(dlgOpen.File.OpenRead());

                    bool lBlnIsColumnRow = true;
                    string lStrLine;
                    while ((lStrLine = lObjStreamReader.ReadLine()) != null)
                    {
                        // lStrLine = lObjStreamReader.ReadLine();


Fully Solution Code:

create list of class object for pass to the webservices as array

        List<SaveCampaignLeads> lArrObjclsGridLoadExcelData = new List<SaveCampaignLeads>();


    private void btnUpload_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                lFnLoadCSVDataInGrid();
              //  tblead = lArrObjclsGridLoadExcelData.ToList();
            
            }

            catch (Exception)
            {
                throw;

            }


Function Upload File:



        public void lFnLoadCSVDataInGrid()
        {
            try
            {
               
                lArrObjclsGridLoadExcelData.Clear();
                int j = 1;
               
                OpenFileDialog dlgOpen = new OpenFileDialog();
                dlgOpen.Filter = "CSV Files (*.csv)|*.csv";
                bool? res = dlgOpen.ShowDialog();

                if (res == true)
                {


                    txtCSV.MaskedText = dlgOpen.File.Name;
                    txtCSV.IsReadOnly = true;

                    StreamReader lObjStreamReader = new StreamReader(dlgOpen.File.OpenRead());

                    bool lBlnIsColumnRow = true;
                    string lStrLine;
                    while ((lStrLine = lObjStreamReader.ReadLine()) != null)
                    {
                        // lStrLine = lObjStreamReader.ReadLine();

                        if (lBlnIsColumnRow)
                        {
                            lBlnIsColumnRow = false;
                            continue;
                        }

                        if (lStrLine == null)
                            break;

                        if (lStrLine.Trim() == "")
                            continue;

                        string[] lArrStrCells = null;

                        lArrStrCells = lStrLine.Split(",".ToCharArray());

                        if (lArrStrCells == null)
                            continue;

                        if (!(lArrStrCells.Length == 11))
                        {
                            MessageBox.Show("CSV file Column greater than required column!","Column Error",MessageBoxButton.OK);
                            continue;
                        }
                       
                      

                        SaveCampaignLeads lObjclsGridLoadExcelData = new SaveCampaignLeads();


                        lObjclsGridLoadExcelData.Leadidpk = j;
                        lObjclsGridLoadExcelData.Listidfk = j;

                        lObjclsGridLoadExcelData.Phonecode = Convert.ToSByte(lArrStrCells[0]);
                        lObjclsGridLoadExcelData.Phonenumber = lArrStrCells[1];
                        lObjclsGridLoadExcelData.Title = lArrStrCells[2];
                        lObjclsGridLoadExcelData.Firstname = lArrStrCells[3];
                        lObjclsGridLoadExcelData.Lastname = lArrStrCells[4];
                        lObjclsGridLoadExcelData.Surename = lArrStrCells[5];
                        lObjclsGridLoadExcelData.Address1 = lArrStrCells[6];
                        lObjclsGridLoadExcelData.Address2 = lArrStrCells[7];
                        lObjclsGridLoadExcelData.City = lArrStrCells[8];
                        lObjclsGridLoadExcelData.State = lArrStrCells[9];
                        lObjclsGridLoadExcelData.Zip = lArrStrCells[10];
                        lObjclsGridLoadExcelData.Datetimecallback = DateTime.Now;
                        lObjclsGridLoadExcelData.Comments = "";
                        lObjclsGridLoadExcelData.Agent = "";
                        lObjclsGridLoadExcelData.Attempts = 0;
                        lObjclsGridLoadExcelData.Lastupdate = DateTime.Now;

                        lArrObjclsGridLoadExcelData.Add(lObjclsGridLoadExcelData);



                        j++;
                    }

                    lObjStreamReader.Close();
                    lObjStreamReader.Dispose();


                }
                //  return lArrObjclsGridLoadExcelData;
            }
            catch (Exception ex)
            {
                txtCSV.Value = "";
              MessageBox.Show(ex.Message.ToString(),"File Upload",MessageBoxButton.OK);
                // return null;
            }
        }


Pass To Web Service upload csv file:

 private void btnSave_Click(object sender, RoutedEventArgs e)
        {

            if (isvalidate())
            {
                this.rbiActivity.IsBusy = true;
                SetMyLeadsWebServiceSoapClient ServiceClient = manager.ServiceClient;
                ServiceClient.ListLeadsSaveCompleted += new EventHandler<ListLeadsSaveCompletedEventArgs>(ServiceClient_ListLeadsSaveCompleted);
                ServiceClient.ListLeadsSaveAsync(this.listpk, this.CampaignId, Convert.ToString(txtName.Value), lArrObjclsGridLoadExcelData.ToArray(), manager.User.Login, manager.User.Password);
                 
            }


            else
            {
                MessageBox.Show(Validation, "Required", MessageBoxButton.OK);

            }
        }
       
        void ServiceClient_ListLeadsSaveCompleted(object sender, ListLeadsSaveCompletedEventArgs e)
        {
            if (e.Error == null)
            {
               
               
                    this.rbiActivity.IsBusy = false;
                 
                    MessageBox.Show(e.Result);
                    this.DialogResult = true;
                    this.Close();
               
            }
        }

        private bool isvalidate()
        {
            List<string> lstError = new List<string>();
            List<string> lstFileError = new List<string>();
            if (Convert.ToString(txtName.Value).Trim().Length == 0)
            {
                lstError.Add("Title field is empty");
            }
            if (Convert.ToString(txtCSV.MaskedText).Trim().Length == 0)
            {
                    lstFileError.Add("File is Empty");
            }

            if (lArrObjclsGridLoadExcelData.Count > 0)
            {
                for (int i = 0; i < lArrObjclsGridLoadExcelData.Count; i++)
                {
                    if(lArrObjclsGridLoadExcelData[i].Phonenumber.Length < 10)
                    {
                        lstFileError.Add("Phone Number should contain at least 10 digits");
                    }
                }
            }
        
            string ErrorMsg = "";
            if (lstError.Count > 0 || lstFileError.Count > 0 )
            {
                if (lstError.Count > 0)
                {
                
                ErrorMsg = "Following are required field.\n\n";
                    foreach (string s in lstError)
                    {
                        ErrorMsg += s + "\n";
                    }
                }
                if (lstFileError.Count > 0)
                {

                    ErrorMsg += "\nUpload File Errors.\n\n";
                    foreach (string s in lstFileError)
                    {
                        ErrorMsg += s + "\n";
                    }
                }

            this.Validation = ErrorMsg;
                return false;
                // 

            }
            else
            {

                return true;
            }

        }


Read in Web Services csv File data to insert db:


 public string ListLeadsSave(int PKListId, int campaignid, string description, List<SaveCampaignLeads> listleads, string Key, string Secret)
        {
            Duplicate = 0;
            SucessfulSave = 0;
            bool result = false;
           

            int listid = 0;
            string message = string.Empty;
            if (Validatuser(Key, Secret))
            {
                bool isNewRecord = false;
                TransactionMgr tx = TransactionMgr.ThreadTransactionMgr();



                try
                {
                    tx.BeginTransaction();
                    tblleads lead = new tblleads();
                    tbllists lst = new tbllists();
                    //user objUser = new user();
                    if (PKListId > 0)
                    {
                        isNewRecord = false;
                        lst.LoadByPrimaryKey(PKListId);
                        lst.Modifieddate = DateTime.Now;

                    }
                    else
                    {

                        isNewRecord = true;
                        lst.AddNew();


                    }

                    lst.Modifieddate = DateTime.Now;
                    lst.Createdate = DateTime.Now;
                    lst.Listdescription = description;
                    lst.Campaignidfk = campaignid;
                    lst.Liststatus = Convert.ToString(Status.Pending);
                    lst.Save();
                    listid = lst.Listidpk;
                    tx.CommitTransaction();


                    if (isNewRecord == true)
                    {
                        for (int j = 0; j < listleads.Count(); j++)
                        {
                            if (MatchPhoneNumber(listleads[j].Phonenumber, campaignid) == false)
                            {
                                result = true;
                                lead.AddNew();
                                SucessfulSave = SucessfulSave + 1;
                                lead.Listidfk = listid;
                                lead.Phonecode = listleads[j].Phonecode;
                                lead.Phonenumber = listleads[j].Phonenumber;
                                lead.Title = listleads[j].Title;
                                lead.Firstname = listleads[j].Firstname;
                                lead.Lastname = listleads[j].Lastname;
                                lead.Surename = listleads[j].Surename;
                                lead.Address1 = listleads[j].Address1;
                                lead.Address2 = listleads[j].Address2;
                                lead.City = listleads[j].City;
                                lead.State = listleads[j].State;
                                lead.Zip = listleads[j].Zip;
                                //  lead.Agent = listleads[j].Agent;
                                lead.Comments = listleads[j].Comments;
                                lead.Datetimecallback = listleads[j].Datetimecallback;
                                lead.Disposition = "1";
                                lead.Attempts = 0;
                                lead.Save();


                            }



                        }
                        if (result == false)
                        {

                            tx.RollbackTransaction();
                            lead.Leadidpk = -1;
                            lead.Save();

                            //message = ("Total Candidated:" + listleads.Count() + ",Success:" + SucessfulSave + ",Duplicate:" + Duplicate);

                        }


                    }

                    if (result == true)
                    {
                        tx.CommitTransaction();
                        message = ("Total Candidate:" + listleads.Count() + ",Success:" + SucessfulSave + ",Duplicate:" + Duplicate);


                    }





                }
                catch (Exception ex)
                {

                    message = ("Total Candidate:" + listleads.Count() + ",Success:" + SucessfulSave + ",Duplicate:" + Duplicate);

                    tx.RollbackTransaction();
                }
            }
            return message;
        }


Match Phone Number already Exist:


        public bool MatchPhoneNumber(string PhNo, int campnid)
        {
            tblleads ld = new tblleads();
            ld.GetleadsByPhoneNumber(PhNo, campnid);
            if (ld.RowCount > 0)
            {
                Duplicate = Duplicate + 1;
                return true;
            }
            else
            {
                return false;
            }
        }



Save Campaign Lead CS File becoz with create this class we can't pass to webservice and give Error.we are using mygeneration software for auto generated class;


namespace SetMyLeads.LOB.MyGeneration.BLL
{
    [Serializable]
    public class SaveCampaignLeads
    {
       


        public   int Leadidpk { get; set; }
        public int Listidfk { get; set; }
        public sbyte Phonecode { get; set; }
        public   string Phonenumber { get; set; }
        public   string Title { get; set; }
        public   string Firstname { get; set; }
        public   string Lastname { get; set; }
        public   string Surename { get; set; }
        public   string Address1 { get; set; }
        public   string Address2 { get; set; }
        public   string City { get; set; }
        public   string State { get; set; }
        public   string Zip { get; set; }
        public DateTime Datetimecallback { get; set; }
        public   string Comments { get; set; }
        public string Agent { get; set; }
        //public   string Disposition { get; set; }
        public int Attempts { get; set; }
        public   DateTime Lastupdate { get; set; }
    }
}



 
Leave a comment

Posted by on July 31, 2012 in Silverlight

 

Tags: , ,

How to get style in code from resource +silverlight


Define style in app file

<Application xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
x:Class=”SetMyLeads.Silverlight.UI.App”
xmlns:telerik=”http://schemas.telerik.com/2008/xaml/presentation&#8221;
xmlns:Telerik_Windows_Controls_MaskedTextBox=”clr-namespace:Telerik.Windows.Controls.MaskedTextBox;assembly=Telerik.Windows.Controls.Input”
xmlns:Telerik_Windows_Controls_Chromes=”clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls”
xmlns:sdk=”http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk&#8221;
xmlns:navigation=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation”
xmlns:System_Windows_Controls_Primitives=”clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls”
xmlns:navPrimitive=”clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls.Navigation”
xmlns:System=”clr-namespace:System;assembly=mscorlib”
xmlns:docking=”clr-namespace:Telerik.Windows.Controls.Docking;assembly=Telerik.Windows.Controls.Docking”

xmlns:telerikDocking=”clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking”

xmlns:Telerik_Windows_Controls_Primitives=”clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls.Navigation”

xmlns:Telerik_Windows_Controls_TabControl=”clr-namespace:Telerik.Windows.Controls.TabControl;assembly=Telerik.Windows.Controls.Navigation”
xmlns:telerikTest=”clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls”>
<Application.Resources>
<!–TextBox Style –>
<Color x:Key=”BackgroundColor”>#FF3D3D3D</Color>
<Color x:Key=”StandardColor”>#FF808080</Color>
<Color x:Key=”HoverColor”>#FFCCCCCC</Color>
<Color x:Key=”PressedColor”>#FFE5E5E5</Color>
<Style TargetType=”telerik:RadMaskedTextBox” x:Key=”DefaultTextBoxStyle”>

<Setter Property=”MaskType” Value=”None”/>
<Setter Property=”Mask” Value=””/>
<Setter Property=”SelectionOnFocus” Value=”CaretToBeginning”/>
<!–<Setter Property=”MaskedText” Value=”” />–>
<Setter Property=”FontSize” Value=”11″ />
<Setter Property=”FontFamily” Value=”Verdana,Times New Roman”  />
<Setter Property=”Foreground” Value=”Black” />
<Setter Property=”SelectionOnFocus” Value=”CaretToBeginning”></Setter>
<Setter Property=”BorderThickness” Value=”1″/>
<Setter Property=”Height” Value=”22″ />
<Setter Property=”TextAlignment” Value=”Left” />
<Setter Property=”HorizontalContentAlignment” Value=”Stretch”/>
<Setter Property=”VerticalAlignment” Value=”Center”/>

<Setter Property=”IsTabStop” Value=”True”/>
<Setter Property=”IsReadOnly” Value=”False”/>
</Style>

</Application.Resources>
</Application>

LabelSr control name

LabelSr.Style = (Style)(Application.Current.Resources[“DefaultLabelLeftStyle”]);

 
Leave a comment

Posted by on June 11, 2012 in Silverlight

 

Call PHP File in Silverlight


you want to call PHP file in silverlight from codebehind then use this code.in this code php file exist on live domain director and you access that file in silverlight with parameters

 

private void phpcall(int campaingid, int batchsize)
{
Uri uri = new Uri(“http://&#8221; + FileHost + “/autodialer/startdial.php?compaignid=” + campaingid + “&batchSize=” + batchsize + “&t=” + DateTime.Now.Millisecond.ToString());

WebClient downloader = new WebClient();
downloader.Encoding = System.Text.Encoding.UTF8;
downloader.DownloadStringCompleted += new DownloadStringCompletedEventHandler(downloader_DownloadStringCompleted);
downloader.DownloadStringAsync(uri, UriKind.Absolute);
}

void downloader_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
if (e.Result != null)
{

//string[] temp = e.Result.ToString().Split(‘,’);
//MessageBox.Show( Convert.ToString(temp[1])+ “testing123”);
MessageBox.Show(“Campaign start successfully.”);
}
}

}

 
Leave a comment

Posted by on April 11, 2012 in Silverlight

 

Tags: ,

How to set image source code behind in silverlight


Hi  Dear…

if your want to change image dynamically of RadGridview in Silverlight with specific Condition then your use this code and be happy

ClientSite

<telerik:GridViewColumn Width=”auto”>
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>

<telerik:RadButton  x:Name=”lbtnInActive”   Command=”Edit” CommandParameter=”{Binding Listidpk}” Click=”lbtnInActive_Click”  >
<telerik:RadButton.Content>
<StackPanel Orientation=”Horizontal” Margin=”0″>
<Image Source=”../Images/icon-Active.png” Width=”30″ Height=”31″ x:Name=”activeICon”/>
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

CodeBehind:

private void grdList_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.DataElement != null)
{
if (e.Row.DataContext != null)
{
var button = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “lbtnInActive”).FirstOrDefault();
var imgicon = e.Row.ChildrenOfType<Image>().Where(b => b.Name == “activeICon”).FirstOrDefault();
tbllists tblst = e.Row.DataContext as tbllists;

if (Convert.ToString(tblst.Liststatus)== “Active”)
{
button.Tag = “Active”;
ToolTipService.SetToolTip(button, “Change Status To InActive”);
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-Active.png”, UriKind.RelativeOrAbsolute));

}
else if (Convert.ToString(tblst.Liststatus)==”InActive”)
{

button.Tag = “InActive”;
ToolTipService.SetToolTip(button, “Change Status To Active”);
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-inactive.png”, UriKind.RelativeOrAbsolute));

}
else {
button.Tag = “Active”;
imgicon.Source = new BitmapImage(new Uri(“../Images/icon-pending.png”, UriKind.RelativeOrAbsolute));
ToolTipService.SetToolTip(button, “Change Pendding To Active”);
}

}
}
}

 

 
Leave a comment

Posted by on March 30, 2012 in Silverlight

 

Tags: , , , , ,

add special char in header RadMenuItem


Special Characters:

Some browsers return escaped text while others return unescaped text. Below is an example of HTML code, how it’s displayed in IE, and how it’s rendered in the DOM Explorer.

 

 

<telerik:RadMenuItem Header=”ReportingPage2″ x:Name=”MyReportingPage2″>

<telerik:RadMenuItem x:Name=”hbtnCampaignSales” Tag=”ReportingPage2/2″

Header=”Campaign &amp; Sale”

Click=”hbtn_Click” Style=”{StaticResource ChildRadMenuItemStyle}” />

</telerik:RadMenuItem>

 

 
Leave a comment

Posted by on March 21, 2012 in Silverlight

 

Tags: , ,

How can i set ToolTip in CodeBehind using Silverlight


hi dear……

ToolTipService.SetToolTip(btnButtonName, “Disable Due to Campaign Currently ” );

 showing a tooltip for disabled control in silverlight CodeBehind

private void grdcampaign_RowLoaded(object sender, RowLoadedEventArgs e)
{

if (e.DataElement != null)
{
if (e.Row.DataContext != null)
{
var btnDelete = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnDelete”).FirstOrDefault();
var btnView = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnView”).FirstOrDefault();

//btnView6
tblcampaign tblst = e.Row.DataContext as tblcampaign;
if (Convert.ToString(tblst.Status) != “Pending”)
{

btnView.IsEnabled = false;
//this Line Show the Tooltip of Disable Button
ToolTipService.SetToolTip(e.Row.Cells[8], “Campaign Currently  ” + tblst.Status);

}
else
{
btnView.IsEnabled = true;
ToolTipService.SetToolTip(btnView, “Campaign Currently  ” + tblst.Status);

}

}
}

}

                     //How can i find RadGridview or datagridview Button Codebehind in Silverlight

var btnDelete = e.Row.ChildrenOfType<RadButton>().Where(b => b.Name == “btnDelete”).FirstOrDefault();

.xaml Side

<telerik:RadGridView x:Name=”grdcampaign” Grid.Row=”2″ Grid.Column=”0″ IsFilteringAllowed=”False”
LoadingRowDetails=”grdcampaign_LoadingRowDetails” RowLoaded=”grdcampaign_RowLoaded”
ColumnWidth=”*”    RowIndicatorVisibility=”Collapsed”
IsReadOnly=”True” AutoGenerateColumns=”False” CanUserFreezeColumns=”False”
CanUserResizeColumns=”False” MinWidth=”1000″  Style=”{StaticResource DefaultGridStyle}”>

<telerik:RadGridView.Columns>
<telerik:GridViewToggleRowDetailsColumn />
<!–<telerik:GridViewImageColumn IsGroupable=”False” IsSortable=”False”
DataMemberBinding=”{Binding Image}” Width=”50″ ImageHeight=”40″ ImageWidth=”40″ />–>
<telerik:GridViewDataColumn UniqueName=”Campaigndesc” Header=”Campaign Name” Width=”.2*”/>
<telerik:GridViewDataColumn UniqueName=”CompanyName” Header=”Company Name” Width=”.1*” />

<telerik:RadButton x:Name=”btnView” Command=”Edit”
CommandParameter=”{Binding Campaignidpk}” BorderThickness=”1″
ToolTipService.ToolTip=”View Leads”  Click=”RadButton_Click”>
<telerik:RadButton.Content>
<StackPanel Orientation=”Horizontal” Margin=”0″ x:Name=”btnView6″  >
<Image Source=”../Images/icon-view.png” Width=”15″ Height=”15″/>
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

<telerik:GridViewColumn Width=”28″>
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<telerik:RadButton  x:Name=”btnDelete” Command=”Delete”
CommandParameter=”{Binding Campaignidpk}”
BorderThickness=”1″ Click=”btnDelete_click” ToolTipService.ToolTip=”Delete” >
<telerik:RadButton.Content>
<StackPanel Orientation=”Horizontal” Margin=”0″>
<Image Source=”../Images/icon-delete.png” Width=”15″ Height=”15″/>
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

</telerik:RadGridView.Columns>
<telerik:RadGridView.RowDetailsTemplate >
<DataTemplate>

<StackPanel Orientation=”Horizontal” HorizontalAlignment=”Stretch”  Margin=”5″ MinWidth=”800″>
<my1:ListCampaignDetail x:Name=”ListCampaignDetail1″ MinWidth=”800″/>

</StackPanel>

</DataTemplate>

</telerik:RadGridView.RowDetailsTemplate>

<i:Interaction.Behaviors>
<local:EmptyDataTemplateBehavior>
<local:EmptyDataTemplateBehavior.EmptyDataTemplate>
<DataTemplate>
<TextBlock Text=”No results found!” Foreground=”red”
HorizontalAlignment=”Center”  VerticalAlignment=”Center” />
</DataTemplate>
</local:EmptyDataTemplateBehavior.EmptyDataTemplate>
</local:EmptyDataTemplateBehavior>
</i:Interaction.Behaviors>
</telerik:RadGridView>
<telerik:RadDataPager Grid.Column=”0″ Grid.Row=”3″ PageSize=”20″ DisplayMode=”All”
AutoEllipsisMode=”Both” NumericButtonCount=”10″ IsTotalItemCountFixed=”True”
Source=”{Binding Items, ElementName=grduser}” />

//How To Get ID of Selected Row in RadGridView

RadButton btnEdit = sender as RadButton;
int Cid = Convert.ToInt32(btnEdit.CommandParameter);

 
Leave a comment

Posted by on March 20, 2012 in Silverlight

 

Tags: , ,

where clause on object C# silverlight


LINQ where clause with lambda expression  With Specific Keyword Show the Data in Silverlight or in WebService

if your create a class object an after filled then your want to load all data from db and restrict on specific keyword data not show ,so you need to apply this method.

Where(x => x.Status != “Complete”).ToList();

if you not use toList() then give you Casting Error so, must use this

This is WebServices Method in silverlight

public List<tblTest> GetCampaignByCompanyId(int companyid)
{
List<tblcampaign> lst = new List<tblcampaign>();

tblcampaign c = new tblcampaign();
c.GetAllCampaignByCompanyId(companyid);
if (c.RowCount > 0)
{
lst = tblcampaign.PopulateCampaign(c).Where(x => x.Status != “Complete”).ToList();
}

return lst;
}

 

or

 

// u.DataTable.Select(“RoleID in (3,4) and isdeleted=0”)

 
Leave a comment

Posted by on March 13, 2012 in Silverlight

 

Tags: ,