That procedure is execute the first time because the page is loaded,
and the data is bind to the formview, but when you are using javascript
calls, no postback is execute, so, you do have a way to solve it.
create a div control on your page, and on LoadData procedure wich will
return a string you create a new FormView, set his properties as you
want, execute the DataBind procedure and through the RenderControl
method you get the html generated by the formview send it to the client
and assign it to the innerHTML propertie of the div.
I don't use Visual Basic, I use C#, but I'll try to write here how you
should do it.
<script type="text/javascript">
        function ChangeData()
        {
                  test.LoadData(document.getElementById("txt").value,
ChangeData_callback);
        }
        function ChangeData_callback(res)
        {
                document.getElementById("mydiv").innetHTML = res.value;
        }
</script>
<div id="mydiv"></div>

the behind code :

dim strDeptCode as string
.....................
.....................
<AjaxMethod()> _
       Public Function LoadData(byVal DeptCode as string) As String
             Dim fv As FormView = New FormView()
             'Set fv properties and the page you want to show
             strDeptCode = DeptCode
             fv.DataBind()
             Dim sb As StringBuilder = New StringBuilder()
             Dim sw As IO.StringWriter = New IO.StringWriter(sb)
             Dim tw As HtmlTextWriter = New HtmlTextWriter(sw)
             fv.RenderControl(tw)
             Return sb.ToString()
       End Sub

       Protected Sub fv_DataBinding(ByVal sender As Object, ByVal e As
System.EventArgs) Handles fv.DataBinding
        If strDeptCode = "" Then
            dsDept.SelectParameters("DeptCode").DefaultValue = "all"
        Else
            dsDept.SelectParameters("DeptCode").DefaultValue =
strDeptCode
        End If
    End Sub

you are not suppose to have an asp:FormView on your  page, but generate
it dinamically, using what I wrote here, otherwise you could only send
the data that will be visible from server to client and  generate with
this data your own html code for a FormView on the cliente , using
javascript, actually that's how I do it.
I hope it could help you.
good luck, if any doubt, ask again.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info/

Don't forget to read my blog at http://weblogs.asp.net/mschwarz/

The open source project is now located at 
http://www.codeplex.com/Wiki/View.aspx?ProjectName=AjaxPro
-~----------~----~----~----~------~----~------~--~---

Reply via email to