Problem with binding data grid on Text Changed Event

5 posts, 0 answers
  1. Durga
    Durga avatar
    3 posts
    Member since:
    Sep 2007

    Posted 25 Feb 2013 Link to this post

    Hi,

    I am rebinding data grind on text changed event. When I changed the text in the text box, the data in the data grid need to reload. If I change the text in the text box which is in first row, the grid is reloading but the text box is missing on first row. But I am not getting issues when I changed the text in other rows.

    I tried both data grid and rad grid.

    I am using the below code,

    .aspx Page Code

    <rad:RadCodeBlock ID="RadCodeBlock1" runat="server">
     

    <asp:datagrid id="Datagrid1" runat="server" Width="100%" AutoGenerateColumns="False" BorderColor="#B6B9BE" BorderWidth="1px" BorderStyle="Solid">
    --Bound columns--
    <asp:TemplateColumn
    <ItemTemplate>

     <asp:TextBox ID="txt_QPercent" runat="server" Width="100%" Text='<%#Container.DataItem("RevisedPercent")%>' onkeydown="return jsDecimals(event,this.value);" MaxLength="3" onchange="SavePercent(this);" OnTextChanged="ReLoadGrid" AutoPostBack="True"></asp:TextBox>

    </asp:TemplateColumn> 

    </ItemTemplate>

     

    </asp:datagrid>


    </rad:RadCodeBlock>

    <rad:RadAjaxManager ID="RadAjaxManager1" runat="server">

     

    <AjaxSettings>

     

    <rad:AjaxSetting AjaxControlID="txt_QPercent"> 
    <UpdatedControls

    <rad:AjaxUpdatedControl ControlID="txt_QPercent" />

    <rad:AjaxUpdatedControl ControlID="DgQAccounts" />

     
    </UpdatedControls>

     

     </AjaxSettings>

     

    </rad:RadAjaxManager>

     


    Code Behind - aspx.vb

    Public

     

    Sub ReLoadGrid(ByVal sender As Object, ByVal e As System.EventArgs)

     

    BindGrid(ID)--Binding the data in the function

     

    End Sub

     


    Thanks,
    Durga Rao
  2. Eyup
    Admin
    Eyup avatar
    3011 posts

    Posted 28 Feb 2013 Link to this post

    Hi Durga,

    Can you please elaborate on your specific scenario? Do you use the Rebind or DataBind method?
    Please note that performing complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, grouping, Paging, Sorting, Filtering require accommodating appropriate database operations.  Therefore, we suggest you to avoid Simple Databinding and strongly recommend the use of more advanced databinding methods, which automatically handle the aforementioned functions:
    Declarative DataSource
    Advanced Data Binding

    Additionally, if you want to modify the grid structure dynamically, please check out the following topic:
    http://www.telerik.com/help/aspnet-ajax/grid-changing-structure-dynamically.html

    Regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Durga
    Durga avatar
    3 posts
    Member since:
    Sep 2007

    Posted 28 Feb 2013 Link to this post

    Hi Eyup,

    I used databind() method to rebind the data. I didn't used any of the operations line insert, delete, edit, sorting and filtering. I am copying the complete code for your reference
    --Data Grid

    <rad:RadCodeBlock ID="RadCodeBlock1" runat="server">

     

     

    <asp:datagrid id="DgQAccounts" runat="server" Width="100%" AutoGenerateColumns="False" BorderColor="#B6B9BE" BorderWidth="1px" BorderStyle="Solid">

     

     

    <HeaderStyle Font-Bold="True" CssClass="DBX.css" BackColor="#EBEBE1"></HeaderStyle>

     

     

    <Columns>

     

     

    <asp:BoundColumn DataField="ActivityCenterNumber" HeaderText="Activity Center #" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" />

     

     

    <asp:BoundColumn DataField="ActivityCenterName" HeaderText="Activity Center Description" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" />

     

     

    <asp:BoundColumn DataField="AccountNumber" HeaderText="Account #" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" />

     

     

    <asp:BoundColumn DataField="AccountName" HeaderText="Account Name" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" />

     

     

    <asp:BoundColumn DataField="AccountType" HeaderText="Account Type" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" />

     

     

    <asp:BoundColumn DataField="Amount" HeaderText="Original Amount" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" DataFormatString="{0:C0}" />

     

     

    <asp:BoundColumn DataField="CacAmount" HeaderText="Final Amount" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="false" DataFormatString="{0:C0}"/>

     

     

    <asp:TemplateColumn HeaderText="Is this RD Account?" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="True" ItemStyle-HorizontalAlign="center">

     

     

    <ItemTemplate>

     

     

    <asp:Panel ID="Panel1" runat="server"><asp:RadioButton ID="rbtn_RnDCostYes" runat="server" GroupName="RBTNRnDCostYesNo" onclick="ValidateRDCheckbox(this)" Text="Yes" Checked='<%#Container.DataItem("IsRDCostYes")%>' />&nbsp;<asp:RadioButton ID="rbtn_RnDCostNo" onclick="ValidateRDCheckbox(this)" runat="server" GroupName="RBTNRnDCostYesNo" Text="No" Checked='<%#Container.DataItem("IsRDCostNo")%>' OnCheckedChanged="ReLoadGrid" AutoPostBack="True" /></asp:Panel>

     

     

    </ItemTemplate>

     

     

    </asp:TemplateColumn>

     

     

    <asp:TemplateColumn HeaderText="PC Revised Q%" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="True">

     

     

    <ItemTemplate>

     

     

    <asp:TextBox ID="txt_QPercent" runat="server" Width="100%" Text='<%#Container.DataItem("PCRevisedPercent")%>' onkeydown="return jsDecimals(event,this.value);" MaxLength="3" onchange="SavePercent(this);" OnTextChanged="ReLoadGrid" AutoPostBack="True"></asp:TextBox>

     

     

    </ItemTemplate>

     

     

    </asp:TemplateColumn>

     

     

    <asp:TemplateColumn HeaderText="Final Amount Reviewed" ItemStyle-CssClass="TableBody8" HeaderStyle-Wrap="True" ItemStyle-HorizontalAlign="center">

     

     

    <ItemTemplate>

     

     

    <asp:label id="lbl_expclassid" runat="server" Text='<%#Container.DataItem("AccountID")%>' CssClass="DoNotShow"></asp:label>

     

     

    <asp:label id="lbl_QNQLevel1ID" runat="server" Text='<%#Container.DataItem("ActivityCenterID")%>' CssClass="DoNotShow"></asp:label>

     

     

    <asp:RadioButton ID="rbtn_IsAmountReviewedYes" runat="server" GroupName="RBTNIsAmountReviewedYesNo" Text="Yes" Checked='<%#Container.DataItem("IsAmountReviewedYes")%>' onclick="ValidateIsAmountReviewedCheckbox(this)" />&nbsp;<asp:RadioButton ID="rbtn_IsAmountReviewedNo" runat="server" GroupName="RBTNIsAmountReviewedYesNo" Text="No" Checked='<%#Container.DataItem("IsAmountReviewedNo")%>' onclick="ValidateIsAmountReviewedCheckbox(this)" />

     

     

    </ItemTemplate>

     

     

    </asp:TemplateColumn>

     

     

    </Columns>

     

     

    </asp:datagrid>

     

     

    </rad:RadCodeBlock>

    --Teleric Calling

     

    <rad:RadAjaxManager ID="RadAjaxManager1" runat="server">

     

     

     

     

     

    <AjaxSettings>

     

     

     

     

     

    <rad:AjaxSetting AjaxControlID="txt_QPercent">

     

     

     

     

     

    <UpdatedControls>

     

     

     

     

     

    <rad:AjaxUpdatedControl ControlID="txt_QPercent" />

     

     

     

     

     

    <rad:AjaxUpdatedControl ControlID="DgQAccounts" />

     

     

     

     

     

    </UpdatedControls>

     

     

     

     

     

    </rad:AjaxSetting>

     

     

     

     

     

    <rad:AjaxSetting AjaxControlID="Panel1">

     

     

     

     

     

    <UpdatedControls>

     

     

     

     

     

    <rad:AjaxUpdatedControl ControlID="Panel1" />

     

     

     

     

     

    <rad:AjaxUpdatedControl ControlID="DgQAccounts" />

     

     

     

     

     

    </UpdatedControls>

     

     

     

     

     

    </rad:AjaxSetting>

     

     

     

     

     

    </AjaxSettings>

     

     

     

     

     

    </rad:RadAjaxManager>

    --Code Behind

     

    Public

     

    Sub ReLoadGrid(ByVal sender As Object, ByVal e As System.EventArgs)

     

    Dim dt As DataTable= Obj.GetQualifiedSnK(InterviewID,

    "K", "tblcontracts")

     

     

    If dt .Rows.Count = 0 Then

     

    DgQAccounts.Visible =

    False

     

     

    Else

     

    DgQAccounts.DataSource = dt 

    DgQAccounts.DataBind()

     

    End If

     

     

    End Sub

    --Comments

    From the above code the error giving control is

     

    <asp:TextBox ID="txt_QPercent" runat="server" Width="100%" Text='<%#Container.DataItem("PCRevisedPercent")%>' onkeydown="return jsDecimals(event,this.value);" MaxLength="3" onchange="SavePercent(this);" OnTextChanged="ReLoadGrid" AutoPostBack="True"></asp:TextBox>

     


    onkeydown="return jsDecimals(event,this.value);"  -  function, I am validating it to allow only numbers
    onchange="SavePercent(this);"  function I am saving the percent to the database using Ajax.
    OnTextChanged="ReLoadGrid" - function will rebind the data to the grid again after saving the percentage.

    When I changed the text on any row except first row, the grid is reloding properly. If I changed the text on first row, the data is saving to the database and the grid is reloading, but the text box on the first row is missing.

    Thanks,
    Durga
  5. Eyup
    Admin
    Eyup avatar
    3011 posts

    Posted 05 Mar 2013 Link to this post

    Hi Durga,

    You will need to modify the ajax settings of the manager. It is sufficient the grid to update itself:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="DgQAccounts">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="DgQAccounts" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    It works as expected on my end. Please give it a try and let me know about the result.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Durga
    Durga avatar
    3 posts
    Member since:
    Sep 2007

    Posted 07 Mar 2013 Link to this post

    Thank You Eyup

    It is working perfectly in my system too.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017