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

Performance using RadGrid for data entry

1 Answer 9 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 27 Aug 2014, 03:02 PM
Greetings,

I have a user control with a RadGrid that I am using for data entry.  I used the examples in the following older posts, and it works, but I am experiencing severe performance issues when the grid grows to about 40 lines

http://www.telerik.com/forums/how-to-add-amp-delete-dynamic-rows-in-radgrid
http://www.telerik.com/forums/dynamically-add-new-rows-to-radgrid

Is there a better way to accomplish multi-line data entry?  I am willing to go a different direction or use a different control if necessary.  Here is my current code...

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="InputFormFundsBreakdown.ascx.cs"
Inherits="Controls_InputFormFundsBreakdown" %>
<table align="left" cellpadding="5" width="100%">
  <tr>
    <td align="center" colspan="2">
      <h3>
        Funds Breakdown
        <asp:Image ID="imgFundsHelp" runat="server" ImageUrl="~/Images/help.png" />
        <telerik:RadToolTip ID="tipFundsHelp" runat="server" HideEvent="LeaveTargetAndToolTip"
                            Position="TopRight" TargetControlID="imgFundsHelp">
          Help goes here
        </telerik:RadToolTip>
      </h3>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <asp:Label ID="errFundsMessage" runat="server" ForeColor="Red"></asp:Label>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <telerik:RadGrid ID="grdFunds" runat="server" AutoGenerateColumns="False" OnDataBound="grdFunds_DataBound"
                       OnNeedDataSource="grdFunds_NeedDataSource">
        <MasterTableView DataKeyNames="RowNumber" AlternatingItemStyle-BackColor="#DAE2E8">
          <ItemStyle VerticalAlign="Top" />
          <Columns>
            <telerik:GridTemplateColumn HeaderText="Fund Name">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundName" runat="server" MaxLength="100" Width="85px"
                                    Text='<%# Eval("FundName")%>'>
                </telerik:RadTextBox>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Fund Number">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundNumber" runat="server" Width="85px" MaxLength="100"
                                    Text='<%# Eval("FundNumber")%>'>
                  <ClientEvents OnKeyPress="NumericOnly" />
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errFundNumber" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Account">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtAccount" runat="server" Width="85px" MaxLength="100" Text='<%# Eval("Account")%>'>
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errAccount" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Subledger">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtSubledger" runat="server" Width="85px" MaxLength="100"
                                    Text='<%# Eval("Subledger")%>'>
                  <ClientEvents OnKeyPress="NumericOnly" />
                </telerik:RadTextBox>
                <br />
                <asp:Label ID="errSubledger" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="T Code">
              <ItemTemplate>
                <asp:HiddenField ID="hdnTCode" runat="server" Value='<%# Eval("TCode")%>' />
                <telerik:RadDropDownList ID="ddlTCode" runat="server" Width="40px">
                  <Items>
                    <telerik:DropDownListItem Value="" Text=" " />
                    <telerik:DropDownListItem Value="W" Text="W" />
                    <telerik:DropDownListItem Value="A" Text="A" />
                  </Items>
                </telerik:RadDropDownList>
                <br />
                <asp:Label ID="errTCode" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="* Amount">
              <ItemTemplate>
                <telerik:RadNumericTextBox ID="txtFundAmount" runat="server" DataType="System.Decimal"
                                           Width="85px" MaxLength="100" NumberFormat-DecimalDigits="2" Type="Currency" DbValue='<%# Eval("Amount")%>'
                                           IncrementSettings-InterceptMouseWheel="False">
                </telerik:RadNumericTextBox><br />
                <asp:Label ID="errFundAmount" runat="server" ForeColor="Red"></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Memo">
              <ItemTemplate>
                <telerik:RadTextBox ID="txtFundMemo" runat="server" Width="145px" Text='<%# Eval("Memo")%>'>
                </telerik:RadTextBox>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn>
              <ItemTemplate>
                <telerik:RadButton ID="btnDeleteFundLine" runat="server" Text="Delete" CssClass="classDeleteImage"
                                   HoveredCssClass="classDeleteHoveredImage" PressedCssClass="classDeletePressedImage"
                                   OnCommand="btnDeleteFundLine_Command" CommandArgument='<%# Eval("RowNumber")%>'>
                  <Image EnableImageButton="true" />
                </telerik:RadButton>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
          </Columns>
        </MasterTableView>
      </telerik:RadGrid>
    </td>
  </tr>
  <tr>
    <td colspan="2">
        
    </td>
  </tr>
  <tr>
    <td>
      <telerik:RadNumericTextBox ID="txtNumberOfRows" runat="server" Width="50px" MinValue="1"
                                 ShowSpinButtons="true" DataType="System.Int32" NumberFormat-DecimalDigits="0" Value="1">
      </telerik:RadNumericTextBox>
      <telerik:RadButton ID="btnAddFundRow" runat="server" Font-Bold="True" Icon-PrimaryIconCssClass="rbAdd"
                         Text="Add Rows" OnClick="btnAddFundRow_Click">
      </telerik:RadButton>
    </td>
    <td align="right">
      <asp:Label ID="lblFundsTotal" runat="server" Font-Bold="true"></asp:Label>  
      <telerik:RadButton ID="btnCalculateFunds" runat="server" Font-Bold="True" Text="Calculate"
                         Icon-PrimaryIconUrl="~/Images/calc.jpg" OnClick="btnCalculateFunds_Click">
      </telerik:RadButton>
    </td>
  </tr>
</table>

using System;
using System.Data;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using dsCashTransmittalTableAdapters;
public partial class Controls_InputFormFundsBreakdown : System.Web.UI.UserControl
{
  public DataTable FundsTable
  {
    get;
    private set;
  }
  protected void Page_Load(object sender, EventArgs e)
  {
    if (ViewState["FundsTable"] == null)
    {
      FundsTable = DefineFundsDataTable();
      AddFiveRows();
    }
    else
    {
      FundsTable = (DataTable)ViewState["FundsTable"];
    }
  }
 
  public decimal CalculateTotal()
  {
    decimal totalAmount = 0;
    try
    {
      foreach (GridDataItem item in grdFunds.Items)
      {
        RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
        totalAmount += Convert.ToDecimal(txtFundAmount.Value);
      }
    }
    catch (Exception)
    {
      totalAmount = 0;
    }
    return totalAmount;
  }
 
  public int CountEntries()
  {
    int cnt = 0;
    try
    {
      foreach (GridDataItem item in grdFunds.Items)
      {
        RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
        if (txtFundAmount.Value != 0)
        {
          cnt++;
        }
      }
    }
    catch (Exception)
    {
      cnt = 0;
    }
    return cnt;
  }
 
  public void ResetValidation()
  {
    errFundsMessage.Text = "";
    foreach (GridDataItem item in grdFunds.Items)
    {
      Label errFundNumber = (Label)item.FindControl("errFundNumber");
      errFundNumber.Text = "";
      Label errAccount = (Label)item.FindControl("errAccount");
      errAccount.Text = "";
      Label errSubledger = (Label)item.FindControl("errSubledger");
      errSubledger.Text = "";
      Label errTCode = (Label)item.FindControl("errTCode");
      errTCode.Text = "";
      Label errFundAmount = (Label)item.FindControl("errFundAmount");
      errFundAmount.Text = "";
    }
    ShowCalculatedTotals();
  }
 
  public void ShowCalculatedTotals()
  {
    lblFundsTotal.Text = "Total: " + CalculateTotal().ToString("C");
  }
 
  public bool ValidateForm(bool valid, ref string logMsg, bool twoFundsRequired, bool oneFundRequired)
  {
    bool hasFund = false;
    bool num = false;
    bool acct = false;
    bool tcode = false;
    bool sub = false;
    //bool amt = false;
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      Label errFundNumber = (Label)item.FindControl("errFundNumber");
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      Label errAccount = (Label)item.FindControl("errAccount");
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      Label errSubledger = (Label)item.FindControl("errSubledger");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      Label errTCode = (Label)item.FindControl("errTCode");
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      //Label errFundAmount = (Label)item.FindControl("errFundAmount");
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      if (txtFundAmount.Text == string.Empty)
      {
        txtFundAmount.Value = 0;
      }
      if (txtFundName.Text != string.Empty ||
          txtFundNumber.Text != string.Empty ||
          txtAccount.Text != string.Empty ||
          txtSubledger.Text != string.Empty ||
          ddlTCode.SelectedValue != string.Empty ||
          txtFundAmount.Value != 0 ||
          txtFundMemo.Text != string.Empty)
      {
        if (txtFundAmount.Value == 0)
        {
          //errFundAmount.Text = "Required";
          //amt = true;
          //txtFundAmount.Focus();
          //valid = false;
        }
        else
        {
          hasFund = true;       
          if (txtSubledger.Text != string.Empty && ddlTCode.SelectedValue == string.Empty)
          {
            errTCode.Text = "Required";
            tcode = true;
            ddlTCode.Focus();
            valid = false;
          }
          else if (ddlTCode.SelectedValue != string.Empty && txtSubledger.Text == string.Empty)
          {
            errSubledger.Text = "Required";
            sub = true;
            txtSubledger.Focus();
            valid = false;
          }
          if (txtAccount.Text == string.Empty)
          {
            errAccount.Text = "Required";
            acct = true;
            txtAccount.Focus();
            valid = false;
          }
          if (txtFundNumber.Text == string.Empty)
          {
            errFundNumber.Text = "Required";
            num = true;
            txtFundNumber.Focus();
            valid = false;
          }
        }
      }
    }
    if (!hasFund && oneFundRequired)
    {
      if (twoFundsRequired)
      {
        errFundsMessage.Text = "Enter at least two funds";
        logMsg = "<li><b>At least two Funds</b> is Required</li>" + logMsg;
      }
      else
      {
        errFundsMessage.Text = "Enter at least one fund";
        logMsg = "<li><b>At least one Fund</b> is Required</li>" + logMsg;
      }
 
      grdFunds.Focus();
      valid = false;
    }
    else
    {
      //if (amt)
      //{
      //  logMsg = "<li><b>Fund Amount</b> is Required</li>" + logMsg;
      //}
      if (tcode)
      {
        logMsg = "<li><b>Fund T Code</b> is Required</li>" + logMsg;
      }
      if (sub)
      {
        logMsg = "<li><b>Fund Subledger</b> is Required</li>" + logMsg;
      }
      if (acct)
      {
        logMsg = "<li><b>Fund Account</b> is Required</li>" + logMsg;
      }
      if (num)
      {
        logMsg = "<li><b>Fund Number</b> is Required</li>" + logMsg;
      }
      UpdateFundTableFromGrid();
    }
    return valid;
  }
 
  public void AddGridErrorMessage(string msg)
  {
    errFundsMessage.Text = msg;
  }
 
  public void ResetForm()
  {
    //FundsTable = DefineFundsDataTable();
    //BindFundGrid();
    ShowCalculatedTotals();
  }
 
  public void LoadForm(CTCommonRequests req)
  {
    FundsTable = LoadFundsDataSource(req.GetCTFundsBreakdown());
    AddFiveRows();
    FillFundFields();
    ShowCalculatedTotals();
  }
 
  public void LoadTemplate(int templateID)
  {
    TemplateFunds_vTableAdapter taFund = new TemplateFunds_vTableAdapter();
    FundsTable = LoadFundsTemplateDataSource(taFund.GetDataByTemplateID(templateID));
    AddFiveRows();
    FillFundFields();
    ShowCalculatedTotals();
  }
 
  public void UpdateFundTableFromGrid()
  {
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      if (Convert.ToDecimal(txtFundAmount.Value) != 0)
      {
        DataRow row = FundsTable.NewRow();
        row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
        RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
        row["FundName"] = txtFundName.Text;
        RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
        row["FundNumber"] = txtFundNumber.Text;
        RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
        row["Account"] = txtAccount.Text;
        RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
        row["Subledger"] = txtSubledger.Text;
        RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
        row["TCode"] = ddlTCode.SelectedValue;
        row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
        RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
        row["Memo"] = txtFundMemo.Text;
        FundsTable.Rows.Add(row);
      }
    }
  }
 
  public void UpdateTemplateFundTableFromGrid()
  {
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      if (txtFundName.Text.Trim() != string.Empty ||
          txtFundNumber.Text.Trim() != string.Empty ||
          txtAccount.Text.Trim() != string.Empty ||
          txtSubledger.Text.Trim() != string.Empty ||
          (ddlTCode.SelectedIndex > -1 && ddlTCode.SelectedValue != "") ||
          txtFundMemo.Text.Trim() != string.Empty)
      {
        DataRow row = FundsTable.NewRow();
        row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
        row["FundName"] = txtFundName.Text;
        row["FundNumber"] = txtFundNumber.Text;
        row["Account"] = txtAccount.Text;
        row["Subledger"] = txtSubledger.Text;
        row["TCode"] = ddlTCode.SelectedValue;
        row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
        row["Memo"] = txtFundMemo.Text;
        FundsTable.Rows.Add(row);
      }
    }
  }
 
  protected void grdFunds_DataBound(object sender, EventArgs e)
  {
    ShowCalculatedTotals();
  }
 
  protected void btnAddFundRow_Click(object sender, EventArgs e)
  {
    ResetValidation();
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      DataRow row = FundsTable.NewRow();
      row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      row["FundName"] = txtFundName.Text;
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      row["FundNumber"] = txtFundNumber.Text;
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      row["Account"] = txtAccount.Text;
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      row["Subledger"] = txtSubledger.Text;
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      row["TCode"] = ddlTCode.SelectedValue;
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      row["Memo"] = txtFundMemo.Text;
 
      FundsTable.Rows.Add(row);
    }
    for (int x = 0; x < txtNumberOfRows.Value; x++)
    {
      FundsTable = AddFundsRow(FundsTable);
    }
    grdFunds.Rebind();
    FillFundFields();
  }
 
  protected void btnDeleteFundLine_Command(object sender, CommandEventArgs e)
  {
    int rowNumber = Convert.ToInt32(e.CommandArgument);
    ResetValidation();
    FundsTable = DefineFundsDataTable();
    foreach (GridDataItem item in grdFunds.Items)
    {
      DataRow row = FundsTable.NewRow();
      row["RowNumber"] = item.GetDataKeyValue("RowNumber").ToString();
      RadTextBox txtFundName = (RadTextBox)item.FindControl("txtFundName");
      row["FundName"] = txtFundName.Text;
      RadTextBox txtFundNumber = (RadTextBox)item.FindControl("txtFundNumber");
      row["FundNumber"] = txtFundNumber.Text;
      RadTextBox txtAccount = (RadTextBox)item.FindControl("txtAccount");
      row["Account"] = txtAccount.Text;
      RadTextBox txtSubledger = (RadTextBox)item.FindControl("txtSubledger");
      row["Subledger"] = txtSubledger.Text;
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      row["TCode"] = ddlTCode.SelectedValue;
      RadNumericTextBox txtFundAmount = (RadNumericTextBox)item.FindControl("txtFundAmount");
      row["Amount"] = Convert.ToDecimal(txtFundAmount.Value);
      RadTextBox txtFundMemo = (RadTextBox)item.FindControl("txtFundMemo");
      row["Memo"] = txtFundMemo.Text;
 
      FundsTable.Rows.Add(row);
    }
    FundsTable = DeleteFundsRow(FundsTable, rowNumber);
    //grdFunds.DataSource = FundsTable;
    grdFunds.Rebind();
    //foreach (GridDataItem item in grdFunds.Items)
    //{
    //  HiddenField hdnTCode = (HiddenField)item.FindControl("hdnTCode");
    //  RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
    //  ddlTCode.SelectedValue = hdnTCode.Value;
    //}
    FillFundFields();
  }
 
  protected void btnCalculateFunds_Click(object sender, EventArgs e)
  {
    lblFundsTotal.Text = "Total: " + CalculateTotal().ToString("C");
  }
 
  private void AddFiveRows()
  {
    for (int x = 1; x < 6; x++)
    {
      FundsTable = AddFundsRow(FundsTable);
    }
    //grdFunds.DataSource = FundsTable;
    grdFunds.Rebind();
  }
 
  private DataTable DefineFundsDataTable()
  {
    DataTable dt = new DataTable("FundsBreakdown");
    DataColumn dc = new DataColumn("RowNumber");
    dc.DataType = Type.GetType("System.Int32");
    dt.Columns.Add(dc);
    dc = new DataColumn("FundName");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("FundNumber");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Account");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Subledger");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("TCode");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    dc = new DataColumn("Amount");
    dc.DataType = Type.GetType("System.Decimal");
    dt.Columns.Add(dc);
    dc = new DataColumn("Memo");
    dc.DataType = Type.GetType("System.String");
    dt.Columns.Add(dc);
    return dt;
  }
 
  private DataTable AddFundsRow(DataTable dt)
  {
    DataRow row = dt.NewRow();
    row["RowNumber"] = dt.Rows.Count + 1;
    row["FundName"] = "";
    row["FundNumber"] = "";
    row["Account"] = "";
    row["Subledger"] = "";
    row["TCode"] = "";
    row["Amount"] = 0;
    row["Memo"] = "";
    dt.Rows.Add(row);
    return dt;
  }
 
  private DataTable DeleteFundsRow(DataTable dt, int deleteRow)
  {
    DataTable deletedRowTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in dt.Rows)
    {
      if (Convert.ToInt32(sourceRow["RowNumber"]) != deleteRow)
      {
        DataRow row = deletedRowTable.NewRow();
        row["RowNumber"] = deletedRowTable.Rows.Count + 1;
        row["FundName"] = sourceRow["FundName"];
        row["FundNumber"] = sourceRow["FundNumber"];
        row["Account"] = sourceRow["Account"];
        row["Subledger"] = sourceRow["Subledger"];
        row["TCode"] = sourceRow["TCode"];
        row["Amount"] = sourceRow["Amount"];
        row["Memo"] = sourceRow["Memo"];
        deletedRowTable.Rows.Add(row);
      }
    }
    return deletedRowTable;
  }
 
  private DataTable LoadFundsDataSource(DataTable sourceDT)
  {
    DataTable filledDataTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in sourceDT.Rows)
    {
      DataRow row = filledDataTable.NewRow();
      row["RowNumber"] = filledDataTable.Rows.Count + 1;
      row["FundName"] = sourceRow["FundName"];
      row["FundNumber"] = sourceRow["FundNumber"];
      row["Account"] = sourceRow["AccountNumber"];
      row["Subledger"] = sourceRow["Subledger"];
      row["TCode"] = sourceRow["TCode"];
      row["Amount"] = sourceRow["FundAmount"];
      row["Memo"] = sourceRow["FundMemo"];
      filledDataTable.Rows.Add(row);
    }
    return filledDataTable;
  }
 
  private DataTable LoadFundsTemplateDataSource(DataTable sourceDT)
  {
    DataTable filledDataTable = DefineFundsDataTable();
    foreach (DataRow sourceRow in sourceDT.Rows)
    {
      DataRow row = filledDataTable.NewRow();
      row["RowNumber"] = filledDataTable.Rows.Count + 1;
      row["FundName"] = sourceRow["TemplateFundName"];
      row["FundNumber"] = sourceRow["TemplateFundNumber"];
      row["Account"] = sourceRow["TemplateAccountNumber"];
      row["Subledger"] = sourceRow["TemplateSubledger"];
      row["TCode"] = sourceRow["TemplateTCode"];
      row["Amount"] = 0;
      row["Memo"] = sourceRow["TemplateFundMemo"];
      filledDataTable.Rows.Add(row);
    }
    return filledDataTable;
  }
 
  private void FillFundFields()
  {
    foreach (GridDataItem item in grdFunds.Items)
    {
      HiddenField hdnTCode = (HiddenField)item.FindControl("hdnTCode");
      RadDropDownList ddlTCode = (RadDropDownList)item.FindControl("ddlTCode");
      if (hdnTCode.Value == "")
      {
        ddlTCode.SelectedIndex = -1;
      }
      else
      {
        ddlTCode.SelectedValue = hdnTCode.Value;
      }
    }
  }
 
  protected void grdFunds_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
  {
    ViewState["FundsTable"] = FundsTable;
    grdFunds.DataSource = FundsTable;
  }
}

Any suggestions for improvement would be greatly appreciated!

Matt

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 28 Aug 2014, 04:11 AM
Hi Matt,

You can take a look at the following help documentation to know how to make your grid more optimized.
Client/server grid performance optimizations

Thanks,
Princy
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or