This is a migrated thread and some comments may be shown as answers.

ASP FormView

1 Answer 54 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 03 Dec 2015, 02:48 PM
I have found very little information on rebinding data in an ASP.NET FormView control without doing a PostBack.

My Scenario is a button on a page with bound FormView data opens a RadWindow and a database edit is done.  Optimally I'd like to have the underlying parent page rebind as soon as the RadWindow database update occurs.

However just to get going I am using RadWindow's OnClientClose to rebind the FormView:

       
<asp:formview id="FormView1" runat="server" enableviewstate="false">
            <ItemTemplate>
                <%# Eval("StreetAddress") %>
            </ItemTemplate>
        </asp:formview>
 
        <telerik:RadWindow
                    ID="EditPermits"
                    runat="server"
                    Height="290px"
                    Width="220px"
                    Top="50px"
                    Left="700px"
                    ReloadOnShow="true"
                    ShowContentDuringLoad="false"
                    Modal="true"
                    OnClientClose="clientClose">
                </telerik:RadWindow>
        <script>
         function clientClose() {
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
                ajaxManager.ajaxRequest();
            }
        </script>
         <telerik:RadAjaxManager
              ID="RadAjaxManager1" runat="server"       
              OnAjaxRequest="RadAjaxManager1_AjaxRequest">
         </telerik:RadAjaxManager>


All the above .aspx code works but where I am confused is the code behind.  Below is my guess on what the code behind would be:

        protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
          {           
              FormView1.DataBind();
          }

1 Answer, 1 is accepted

Sort by
0
Kyle
Top achievements
Rank 1
answered on 03 Dec 2015, 02:52 PM

Here is where I bind the FormView initially:

   

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        if ((Session["AccessLevel"].ToString() == "admin") || (Session["AccessLevel"].ToString() == "worker"))
        {
            if (Request.QueryString["status"] == "Yellow")
            {
                SqlConnection con = new SqlConnection(connectionString);
                con.Open();
                string qry = "SELECT StreetAddress FROM [User]";
                SqlCommand cmd = new SqlCommand(qry, con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                FormView1.DataSource = dt;
                FormView1.DataBind();
                con.Close();
            }

Tags
Ajax
Asked by
Kyle
Top achievements
Rank 1
Answers by
Kyle
Top achievements
Rank 1
Share this question
or