Category Archives: TextBox

[RESOLVED] FindControl method doesn't work with masterpage

Hi all, i have a masterpage and other pages. i want to use findcontrol method to find a textbox (not on the master page) to check whether it is empty or not.

my code is as folows;

Dim myContentPlaceHolder As ContentPlaceHolder = CType(Master.FindControl("MainContent"), ContentPlaceHolder)

Dim UpdatePanel1 As UpdatePanel = CType(myContentPlaceHolder.FindControl("UP1"), UpdatePanel)

Any help please. 

 

Dim tmptxt As TextBox = CType(Master.FindControl("txtbox1"), TextBox)


If Not tmptxt Is Nothing Then
 'get tmptxt.Text value
End If


my textbox in not on the masterpage, it is on the default.aspx page. i tried

Dim myTextBox As TextBox = CType(Master.FindControl("TextBox1"), TextBox)  , but doesn't worked. Any more help please

i should also mention that the TextBox1 is inside listview, the listview is inside an updatepanel (updatepanel is inside a panel -ajax modalpopupextender).

Hi,

First you need to find the textbox in listview. Since I'm not sure which textbox you find in listview. Here's a example:

<asp:ListView ID="ListView1" runat="server">
            <ItemTemplate>
                <tr id="Tr2" runat="server">
                    <td align="center">
                        <asp:Label ID="lbP1" runat="Server" Text='<%#Eval("P1") %>' />
                    </td>
                    <td align="center">
                        <asp:Label ID="lbP2" runat="Server" Text='<%#Eval("P2") %>' />
                    </td>
                   

                </tr>
            </ItemTemplate>
</asp:ListView>
Protected Sub FindItems()
	Dim ctl As Control = Me.ListView1.Items(0).FindControl("lbP1")  //find textbox in the first item of ListView
End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs)
	FindItem()
End Sub


Find the child page's ListView in masterpage:

Dim panel As UpdatePanel = TryCast(Me.ContentPlaceHolder1.FindControl("UpdatePanelID"), UpdatePanel)
Dim listview As ListView = TryCast(panel.FindControl("ListViewID"), ListView)


Please notice that if the control is wrapped in a parent control, you need to first find the control from this parent control(container).

Here are some good article:

http://weblogs.asp.net/dwahlin/archive/2006/08/25/Finding-ASP.NET-Child-Controls_2E002E002E002E00_The-Simple-Way.aspx

http://www.west-wind.com/Weblog/posts/5127.aspx

Hope this can help you.
 

Back button functionality in web page

Hi,


In one of the pages of my web applicaiton developed using VS 2005, I have a textbox. When the user enters soem text in the textbox and clicks search button, then I retrieve data pertaining to teh search string and display the same in a datagrid. In teh datagrid, each row represents a report and there is a hyperlink column. Clickign on this column would take the user to another page which displays the complete details of the report. Now I want to provide a back button in the 2nd page(where the complete details of the report are displayed) so that the user can go back to the previous page where he entered the search criteria. I have placed the back button in the second page. In the Click event handler of the  back button, when I give a Response.redirect or Server.Transfer, it takes me to the previous page. This is the expected expected behaviour. But I want the page to be the same as it was before leaving it.

For example, If in Page1, I entered the search criteria as msdn and clicked on search, then a datagrid pertainign to this would be dispalyed with say 10 rows. I click ont eh hyperlink in one of the rows ato view the complete details. In Page 2, click Back button. Now I should be redirected to page 1 and the page 1 should contain the search criteria as msdn and the datagrid pertainign to this should also be displayed. How do I achive this?

Thanks,
Sandhya

Dear Sandhya, Please try the following steps. 1. Add a ASP button to a page namely e.g btnBack 2. In page load event write btnBack.Attributes.Add("onclick","history.back()"); Try it. i hope this will help you
Hi,
Try the following code... 
Response.Redirect(Request.UrlReferrer.ToString())
Or 

use history.go(-2)  it take you  two pages back.

eg.
<asp:LinkButton ID="LinkButtonBack" runat="server" CausesValidation="false" PostBackUrl="javascript:history.go(-1);">Back</asp:LinkButton><br/>

Hope it helps...

~Jagadeesh

 

--- Mark as answer if the post meets your requirement! 

 

 

If page1 is simply displaying search results then you can pass the search term back from page2 using querystring.

1. Page1 passes search term to Page2 ( Response.Redirect("Page2.aspx?searchterm=msdn&otherparameters=xyz") )

2. Page2 stores searchterm in viewstate and displays details

3. Page2 displays aBack button, which on click calls Response.Redirect("Page1.aspx?searchterm=msdn")

4. Page1's page load event checks if a searchterm has been passed, if so then get the results

page1's page load event

if(!Page.IsPostBack)

{

if (Request.QueryString["searchterm"] != null)

{

LoadResults for search term

}

}

 

I had the exact same problem. I placed the following in the Client script. No Server side code was needed:

 

<asp:LinkButton ID="LinkButtonClose" runat="server" CausesValidation="false" PostBackUrl="javascript:history.go(-1);">Close</asp:LinkButton><br/>
 

Hi,

I tried the same. But history.back() does n't work forme. So I tried adding a link button and set the PostBackUrl property to history.back(-1) and it worked. Why didn't it work for the button control? Any idea?

 Thanks,

Sandhya

 Thank u.

 Hi,

 Use below  example

protected void Page_Load(object sender, EventArgs e)
    {      
        if (!IsPostBack)
        {

        if (Convert.ToString(Session["Action"]) == "search")
        {
            txtSearch.Text = Convert.ToString(session["SearchText"]);
                

//Call the appropriate function for search

           Search();

        }

    }

}


//HyperLink OnCommand=" OnCommand_lnkName"

protected void OnCommand_lnkName(object sender, CommandEventArgs e)
    {

session["SearchText"] = txtSearch.Text;
Session["Action"] = "Search";

    }

thanx Bill .......   this is perfect code n it worked for me :) :)Cool 

[RESOLVED] Passing Values Between Two application

hi Everyone..

i have to pass a value in the textbox in one application to another one in run time. Two web application resides in the same Solution. how can i do it?

please help me on this I am Stuck up on this!

Thanks and regards

Hi

You can either use Referance of DLL or you can use Call Remote Oblect Call to achieve this functionality. 

pareshsoni

i have to pass a value in the textbox in one application to another one in run time. Two web application resides in the same Solution. how can i do it?

please help me on this I am Stuck up on this!

 

You can use Form PostQuery String etc..

Hi,

Thanks For your Reply,

I did all the method of the Querystring.but its not coming as i desired.

if You hv any other solution so plese forward it...

thank you

Hi,

The best option is Querystring to pass the value, but as you said that it’s not working. Therefore I found a solution. I’m sure it would be useful for you:

http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

There are lots of source codes. Implement these on your application.

Hi David,

Thank you for ur Reply,

now i am pretty much confused, it would be greatfull, if u can  Show a code or can u do a Demo and Show Me ..

Thank you



read this heading

Getting Post Information from the Source Page in Another Application

in the link

http://msdn.microsoft.com/en-us/library/6c3yckfw%28v=VS.80%29.aspx#Y2394

Hi,

Here's a good article to show you how to do a data transfer between two page or application.

http://www.intstrings.com/ramivemula/articles/data-transfer-between-two-asp-net-pages/

Hope this can help you.

There are many option to handle this kind of situations...

1. You can pass value from query string (very quick view) by respose.redirect URL with query string value.

2. You can submit your from by post methid with action url as another web site url and get that value with request.form[] variable.

 

So please post your exact senario then I can provide you exact soluton apporaches.

 

[RESOLVED] <button disable="disable" does not work if I want to disable behind

I have the following: I would like to disable protected void btnSend_Click(object sender, EventArgs e) { if (Page.IsValid) { btnSend.Disabled = true; System.Threading.Thread.Sleep(2000); } this does not wor

I have the following:
<button id="btnSend" runat="server" alt="" CausesValidation="false" önserverclick="btnSend_Click">
<img id="imgSend" alt="" runat="server" src="~/Images/Buttons/send_ico.gif"
align="top" />


 Send Message</button>


I would like to disable


protected void btnSend_Click(object sender, EventArgs e)
{


if (Page.IsValid)
{
btnSend.Disabled = true;
System.Threading.Thread.Sleep(2000);
}
this does not work.


k.

Can you explain what you are tyring to do? Disabling button when page is valid to stop duplicate postbacks. If so, you can do this...

Markup:

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="WebForm5.aspx.cs"
    Inherits="WebApplication1.WebForm5" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ErrorMessage="Required" ControlToValidate="txt" ForeColor="Red"
        Display="Dynamic" SetFocusOnError="true" runat="server" />
    <asp:Button ID="buttonSave" runat="server" CausesValidation="true" Text="Do Something"
        OnClick="buttonSave_Click" />
    </form>
</body>
</html>

CodeBehind:

protected void Page_Load(object sender, EventArgs e)
{
    buttonSave.Attributes.Add("onclick""Page_ClientValidate();if(Page_IsValid){this.disabled=true;" +
                                Page.ClientScript.GetPostBackEventReference(buttonSave, "Test") + ";}");

}
protected void buttonSave_Click(object sender, EventArgs e)
{
    Thread.Sleep(2000);
}

Try that way and see if it works. Button will be disabled when page is valid.

sometimes the user can click the button twice.

I want to disable this.

 

buttonSave.Attributes.Add("onclick""Page_ClientValidate();if(Page_IsValid){this.disabled=true;" +
                                Page.ClientScript.GetPostBackEventReference(buttonSave, "Test") + ";}");

this is only good for the asp.net button asp:button tag.

 

<button id="btnSend" runat="server" alt="" CausesValidation="true" onserverclick="btnSend_Click">
                        <img id="imgSend" alt="" runat="server" src="~/Images/Buttons/send_ico.gif"
                            align="top" />
                        <span> <b class="va">Send Message</b></span></button>


this is a html button.

it does not work like a asp:button.

Hi,

Accroding to your code, it seems that the button will be disabled after 2 seconds. Is it what you want to implement?

If I'm not misundertood you, you can try to comment the code "System.Threading.Thread.Sleep(2000)".

Or use the client side javascript:

btnSend.Attributes["onclick"] = "this.disabled = true;";

Here System.Threading.Thread.Sleep(2000) is used to do a delay time manually in order to let us see how this disable property affect the button before the button sumbit.

Above poster give you a good example, whatever the button is asp:button or HtmlButton. It should always work.

I modify it for HtmlButton:

protected void Page_Load(object sender, EventArgs e)
        {
           btnSend.Attributes["onclick"] = "this.disabled = true;";
         }






        protected void btnSend_Click(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(2000);
        }


 <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <button id="btnSend" runat="server" alt="send" causesvalidation="false"  onserverclick="btnSend_Click">
                        <img id="img1" alt="" runat="server" src="~/Images/20100920105445544.jpg" align="top" />
                        Send Message</button>
                </ContentTemplate>
            </asp:UpdatePanel>


The button will disabled 2 seconds.

Hope this can help you.

Accessing Database from Silverlight

Hi All,

I am working on Silverlight 2 Beta 2. I ma trying to bind the data to a DataGrid from the DB using LINQ. When I search in the net all articles are talking about binding the data using WCF Service only.

Without WCF we cannot bind the Data?

 I want to design a DataGrid like below


___________________________________________________
|               |                |               Number of                               |
|               |                |___________________________________|
|Column1  |Column 2 |SubColumn1|SubColumn2|SubColumn3|
|________|________ |__________|__________|____________|
| 1          |  a          | as            | fg             | gh            |
| 2          |  b          | sd            | fg             | fgh           |
| 3          |  c          | df             | fg             | fgf           |
________________________________________________

Total     | Total of this Col | same | same...

Let me know

Thanks

Anandraj.A.

You have only 2 method to bind grid in the silver light 1). WCF and 2). Web service (asmx).
1. Create Interface for Datagrid(classes, methods)
2. Create User Control as a Label
3. You have to design a datagrid as your wish by the user control or any.
4. Place table-data into the Label-User-Control through WCF

Note: Dropdown also possible by User Control


 Hi Anandraj

it is a little tricky at best to get databinding in silverlight,  take a look at these videos should help. ado.net data services made life a little easier (but not much) seems to be the way to go.but im not sure if it works with beta, any reason you are using beta?

http://www.microsoft.com/uk/msdn/screencasts/screencast/308/adonet-data-services-a-basic-silverlight-client.aspx

Im not sure about doing it with silverlight 2 beta either?, I know the datagrid changed at some point from beta to live (i think anyway) so you may hit a problem with that.

Hi anand,

WCF is the most suitable way to bind the data in Silverlight applications. We can use LINQ TO SQL classes to create the data layer mapped over SQL Server tables. Further by creating Silverlight-enabled-WebService we can access above created LINQ classes to access the data and fetching to Silverlight application.

First create a silverlight application.

Secondly,

Now that you have created the Silverlight 3 Application, we would add a LINQ to SQL file that is *.dbml .

LinqToSQLSilverlight2.gif


Thirdly,

To communicate with LINQ to SQL we need to have a service that client can call at any time.

Add Silverlight enabled WCF Service to the Web Project.

LinqToSQLSilverlight7.gif


In the Service.svc.cs add methods as per your requirement.

I have written two methods such as:


#region [GetAllEmployees]


        [OperationContract]
        List<vw_mst_EmployeeDetail> GetAllEmployees()
        {
            using (EmployeeDBDataContext context = new EmployeeDBDataContext())
            {
                var result = from emp in context.vw_mst_EmployeeDetails
                             select emp;


                return result.ToList();
            }
        }


        #endregion


        #region [GetEmployeesByFirstName]


        [OperationContract]
        List<vw_mst_EmployeeDetail> GetEmployeesByFirstName(string firstName)
        {
            using (EmployeeDBDataContext context = new EmployeeDBDataContext())
            {
                var result = from emp in context.vw_mst_EmployeeDetails
                             where emp.FirstName.StartsWith(firstName)
                             select emp;


                return result.ToList();
            }
        }


        #endregion


Fourthly,

After writing the service build the project and get this service's reference in Silverlight 3 Project as shown in below figure.

LinqToSQLSilverlight10.gif


<div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        #region [GetAllEmployees]</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        [OperationContract]</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        List<vw_mst_EmployeeDetail> GetAllEmployees()</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        {</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            using (EmployeeDBDataContext context = new EmployeeDBDataContext())</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            {</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                var result = from emp in context.vw_mst_EmployeeDetails</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                             select emp;</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                return result.ToList();</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            }</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        }</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        #endregion</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        #region [GetEmployeesByFirstName]</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        [OperationContract]</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        List<vw_mst_EmployeeDetail> GetEmployeesByFirstName(string firstName)</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        {</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            using (EmployeeDBDataContext context = new EmployeeDBDataContext())</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            {</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                var result = from emp in context.vw_mst_EmployeeDetails</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                             where emp.FirstName.StartsWith(firstName)</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                             select emp;</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">                return result.ToList();</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">            }</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        }</div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"></div> <div style="position: absolute; left: -10000px; top: 926px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">        #endregion</div>

After you add the service it would create the ServiceReferences.ClientConfig file.

Now it's time to design our Silverlight UI in Blend, I have gone for a simple approach, where simple buttons and textbox would help us getting the result which would be displayed in DataGrid.


LinqToSQLSilverlight11.gif


XAML for your reference is as follows - 


<UserControl

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

    mc:Ignorable="d" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" x:Class="Mazeweb.Silverlight.MainPage"

    d:DesignWidth="640" d:DesignHeight="480">

    <Grid x:Name="LayoutRoot">

     <Grid.Background>

     <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">

     <GradientStop Color="#FFF2F2F8" Offset="0.948"/>

     <GradientStop Color="#FF5B99F2" Offset="0.665"/>

     </LinearGradientBrush>

     </Grid.Background>

     <Grid.RowDefinitions>

     <RowDefinition Height="0.106*"/>

     <RowDefinition Height="0.056*"/>

     <RowDefinition Height="0.838*"/>

     </Grid.RowDefinitions>

        <TextBlock HorizontalAlignment="Center" Text="LINQ TO SQL &amp; SILVERLIGHT 3" 

             TextWrapping="Wrap" FontSize="21.333" TextDecorations="Underline" Margin="0,3,0,19" d:LayoutOverrides="Height"/>

        <StackPanel Margin="0" Height="80" VerticalAlignment="Center" Orientation="Horizontal" 

                    HorizontalAlignment="Center" Grid.Row="1">

            <Button x:Name="btnAll" Height="25" Content="Show All" Click="btnAll_Click" VerticalAlignment="Center" Margin="0,0,0,8" Width="109" />

            <Rectangle Height="25" Width="10"/>

            <TextBox x:Name="txtName" Height="25" TextWrapping="Wrap" Width="164" VerticalAlignment="Center"/>

            <Rectangle Height="25" Width="10"/>

            <Button x:Name="btnSubmit" Height="25" Content="Search" Click="btnSubmit_Click" VerticalAlignment="Center" Margin="0,0,0,8" Width="109" />

        </StackPanel>

        <data:DataGrid x:Name="dgResults" Margin="8,10,8,89" Grid.Row="2" IsReadOnly="True" 

                       AutoGenerateColumns="False">

            <data:DataGrid.Columns>

                <data:DataGridTextColumn Binding="{Binding ID}" Header="ID"></data:DataGridTextColumn>

                <data:DataGridTextColumn Binding="{Binding FirstName}" Header="First Name"></data:DataGridTextColumn>

                <data:DataGridTextColumn Binding="{Binding LastName}" Header="Last Name"></data:DataGridTextColumn>

                <data:DataGridTextColumn Binding="{Binding UserCode}" Header="EmailID"></data:DataGridTextColumn>

                <data:DataGridTextColumn Binding="{Binding DesignationName}" Header="Designation"></data:DataGridTextColumn>

                <data:DataGridTextColumn Binding="{Binding BranchName}" Header="Branch"></data:DataGridTextColumn>

            </data:DataGrid.Columns>

        </data:DataGrid>

    </Grid>

</UserControl>

<div>
</div><div>
</div><div>Finally,</div><div>
</div><div>Now we would write client side code to call the service and display the result.

Following code is for Show All Button Click and displaying the result.
</div><div>
</div><div><div>        private void btnSubmit_Click(object sender, RoutedEventArgs e)</div><div>        {</div><div>            ServiceClient clientService = new ServiceClient();</div><div>            clientService.GetEmployeesByFirstNameCompleted += new EventHandler<GetEmployeesByFirstNameCompletedEventArgs>(clientService_GetEmployeesByFirstNameCompleted);</div><div>            clientService.GetEmployeesByFirstNameAsync(txtName.Text);</div><div>        }</div><div>
</div><div>        void clientService_GetEmployeesByFirstNameCompleted(object sender, GetEmployeesByFirstNameCompletedEventArgs e)</div><div>        {</div><div>            dgResults.ItemsSource = e.Result;</div><div>        }</div><div>
</div><div>        private void btnAll_Click(object sender, RoutedEventArgs e)</div><div>        {</div><div>            ServiceClient clientService = new ServiceClient();</div><div>            clientService.GetAllEmployeesCompleted += new EventHandler<GetAllEmployeesCompletedEventArgs>(clientService_GetAllEmployeesCompleted);</div><div>            clientService.GetAllEmployeesAsync();</div><div>        }</div><div>
</div><div>        void clientService_GetAllEmployeesCompleted(object sender, GetAllEmployeesCompletedEventArgs e)</div><div>        {</div><div>            dgResults.ItemsSource = e.Result;</div><div>        }</div><div>
</div><div>
</div><div>Now, Finally you can test your application successfully running.</div>
</div>


Hope this POST helps.


I wrote an article about connecting a datagrid to a silverlight project here. Perhaps it will be useful.

Hi Dear

You have three option

1: Linq to Sql server

2. WCF Service

3. Web Service