ASP FormView

2 posts, 0 answers
  1. Kyle
    Kyle avatar
    2 posts
    Member since:
    Nov 2015

    Posted 03 Dec 2015 Link to this post

    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();
              }

  2. Kyle
    Kyle avatar
    2 posts
    Member since:
    Nov 2015

    Posted 03 Dec 2015 in reply to Kyle Link to this post

    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();
                }

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top