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

grid columns not bound

3 Answers 171 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 18 Feb 2014, 01:26 PM
I have a project that I have been away from for a period of time and everything was working just fine, but when I came back to it to complete development, I have run into an issue with some of the grids not showing data in columns, but rather just "dumping it" in one long string.

I have attached a screen capture of the result, as well as display file and code behind.  Any chance you can tell me why the grid is doing this?

Thanks in advance for any assistance!

Lynn

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h3>
    <asp:Label ID="ListHeader" runat="server" Text="Agents" ></asp:Label>
</h3>
<p>
    <asp:Label ID="ListExplanation" runat="server" Text="Real estate agents in your organization" ></asp:Label>
</p>
<div class="container">
    <div class="row10">
        <div class="one column" >
              
        </div>
        <div class="fourteen columns" >
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="True" OnNeedDataSource="RadGrid1_NeedDataSource" Width="99.7%"
                AutoGenerateColumns="false" AllowPaging="false" OnItemDataBound="RadGrid1_ItemDataBound"  AllowFilteringByColumn="True">
                <ExportSettings HideStructureColumns="true" Csv-ColumnDelimiter="Comma" IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true" >
                </ExportSettings>
                <MasterTableView Width="100%" CommandItemDisplay="Top" EnableViewState="true">
                    <PagerStyle Mode="Slider"></PagerStyle>
                    <CommandItemTemplate>
                        <table class="rcCommandTable" width="100%">
                            <tr>
                            <td style="float: right; vertical-align:middle;" >
                                <asp:ImageButton runat="server" ID="btnCSVExport" ImageUrl="../Icons/csvdownload.jpg" CommandName="ExportToCSV" Height="24px" Width="24px" ToolTip="Export to CSV" />
                                <asp:ImageButton runat="server" ID="btnExcelExport" ImageUrl="../Icons/excel.png" CommandName="ExportToExcel" Height="24px" Width="24px" ToolTip="Export to Excel" />
                                <asp:ImageButton runat="server" ID="btnWordExport" ImageUrl="../Icons/ms_word_2.png" CommandName="ExportToWord" Height="24px" Width="24px" ToolTip="Export to Word" />
                                  
                            </td>
                            </tr>
                        </table>
                    </CommandItemTemplate>
                    <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" ShowExportToCsvButton="true" ShowExportToPdfButton="false">
                    </CommandItemSettings>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
        <div class="one column" >
              
        </div>
    </div>
</div>


protected void Page_Init(object sender, System.EventArgs e)
{
    if (!Page.IsPostBack)
    {
        sType = Request["T"];
        //  Get the users form security rules and set the buttons accordingly
        string sUserFormRules = Convert.ToString(Session["UserBrokerPlusFormsRules"]);
        string sRule = "";
        switch (sType)
        {
            case "A":   //  Active
                this.ListHeader.Text = "Active Agents";
                this.ListExplanation.Text = "Real estate agents presently working for your organization";
                sRule = sUserFormRules.Substring(21, 1);
                break;
            case "I":   //  Inactive
                this.ListHeader.Text = "Inactive Agents";
                this.ListExplanation.Text = "Real estate agents that are not working for your organization but are still on the roster";
                sRule = sUserFormRules.Substring(22, 1);
                break;
            case "T":    //  Terminated
                this.ListHeader.Text = "Terminated Agents";
                this.ListExplanation.Text = "Real estate agents that worked for your organization in the past";
                sRule = sUserFormRules.Substring(23, 1);
                break;
            default:
                Response.Redirect("~/UserNotAuthorized.aspx");
                break;
        }
        switch (sRule)
        {
            case "0":
                //  the user is not authorized for this page, so send them to the error page
                Response.Redirect("~/UserNotAuthorized.aspx");
                break;
            case "1":
                //  The user is only authorized for read-only activities, so set the buttons accordingly
                this.CreateNew.Enabled = false;
                break;
            case "2":
                //  The user is authorized to update data, so leave the buttons as is
                break;
        }
 
        this.RadGrid1.AllowFilteringByColumn = true;
        GridHyperLinkColumn hypercolumn = null;
        GridBoundColumn boundcolumn = null;
 
        hypercolumn = new GridHyperLinkColumn();
        this.RadGrid1.Columns.Add(hypercolumn);
        hypercolumn.HeaderText = "Edit";
        hypercolumn.UniqueName = "Agent";
        hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/pencil_16.png\" />";
        hypercolumn.DataNavigateUrlFields = new string[] { "Agent" };
        hypercolumn.DataNavigateUrlFormatString = "OfcAgentEdit.aspx?M=Y&T=" + sType + "K=" + "{" + "0" + "}";
        hypercolumn.AllowFiltering = false;
        hypercolumn.HeaderStyle.Width = Unit.Pixel(50);
        hypercolumn.Exportable = false;
        hypercolumn = null;
 
        hypercolumn = new GridHyperLinkColumn();
        this.RadGrid1.Columns.Add(hypercolumn);
        hypercolumn.HeaderText = "Email";
        hypercolumn.UniqueName = "SendAgentMail";
        hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/mailIcon.gif\" />";
        hypercolumn.DataNavigateUrlFields = new string[] { "AgentEmail" };
        hypercolumn.DataNavigateUrlFormatString = "mailto:" + "{" + "0" + "}";
        hypercolumn.HeaderStyle.Width = Unit.Pixel(30);
        hypercolumn.AllowFiltering = false;
        hypercolumn.Exportable = false;
        hypercolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentID";
        boundcolumn.DataField = "AgentID";
        boundcolumn.HeaderText = "ID";
        boundcolumn.FilterControlWidth = Unit.Pixel(50);
        boundcolumn.HeaderStyle.CssClass = "mediumgridcol";
        boundcolumn.ItemStyle.CssClass = "mediumgridcol";
        boundcolumn.FooterStyle.CssClass = "mediumgridcol";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentFullName";
        boundcolumn.DataField = "AgentFullName";
        boundcolumn.HeaderText = "Name";
        boundcolumn.HeaderStyle.Width = Unit.Pixel(240);
        boundcolumn.FilterControlWidth = Unit.Pixel(100);
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        //  this code is left here as a working example of displaying a short date in a RadGrid column
        //boundcolumn = new GridBoundColumn();
        //this.RadGrid1.Columns.Add(boundcolumn);
        //boundcolumn.UniqueName = "NewsEndDate";
        //boundcolumn.DataField = "NewsEndDate";
        //boundcolumn.HeaderText = "End";
        //boundcolumn.DataFormatString = "{0:MM/dd/yy}";
        //boundcolumn.Visible = true;
        //boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "OfficeCommonName";
        boundcolumn.DataField = "OfficeCommonName";
        boundcolumn.HeaderText = "Office";
        boundcolumn.FilterControlWidth = Unit.Pixel(100);
        boundcolumn.HeaderStyle.CssClass = "largegridcol";
        boundcolumn.ItemStyle.CssClass = "largegridcol";
        boundcolumn.FooterStyle.CssClass = "largegridcol";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentCellular";
        boundcolumn.DataField = "AgentCellular";
        boundcolumn.HeaderText = "Cellular";
        boundcolumn.FilterControlWidth = Unit.Pixel(60);
        boundcolumn.HeaderStyle.CssClass = "smallgridcol";
        boundcolumn.ItemStyle.CssClass = "smallgridcol";
        boundcolumn.FooterStyle.CssClass = "smallgridcol";
        boundcolumn.Visible = true;
        boundcolumn = null;
 
        boundcolumn = new GridBoundColumn();
        this.RadGrid1.Columns.Add(boundcolumn);
        boundcolumn.UniqueName = "AgentEmail";
        boundcolumn.DataField = "AgentEmail";
        boundcolumn.HeaderText = "Email";
        boundcolumn.HeaderStyle.CssClass = "smallgridcol";
        boundcolumn.ItemStyle.CssClass = "smallgridcol";
        boundcolumn.FooterStyle.CssClass = "smallgridcol";
        boundcolumn.Visible = true;
        boundcolumn.FilterControlWidth = Unit.Pixel(100);
        boundcolumn = null;
 
        RadGrid1.AllowPaging = Convert.ToBoolean(Session["ShowListsWithPaging"]);
        RadGrid1.PageSize = 20;
    }
    else
    {
        sType = Request["T"];
    }
}
 
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    //  this code is used to make filter columns visible/invisible as the grid grows/shrinks
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem Filter = (GridFilteringItem)e.Item;
        Filter["AgentID"].CssClass = "mediumgridcol";
        Filter["OfficeCommonName"].CssClass = "largegridcol";
        Filter["AgentCellular"].CssClass = "smallgridcol";
        Filter["AgentEmail"].CssClass = "smallgridcol";
    }
    ////  this code is left here for a working example of modifying column contents in a RadGrid
    //if (e.Item is GridDataItem)
    //{
    //    GridDataItem dataBoundItem = e.Item as GridDataItem;
    //    string strColumnValue1 = dataBoundItem["VendorShowInLists"].Text;
    //    if (strColumnValue1 == "0")
    //    {
    //        dataBoundItem["VendorShowInLists"].Text = "No";
    //    }
    //    else
    //    {
    //        dataBoundItem["VendorShowInLists"].Text = "Yes";
    //    }
    //}
}
 
protected void CreateNew_Click(object sender, EventArgs e)
{
    Response.Redirect("OfcAgentEdit.aspx?M=N&K=&T=" + sType);
}
 
public DataTable GetDataTable()
{
    String ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString;
    DataTable dt = new DataTable();
        string sStatusNeeded = "";
        switch (sType)
        {
            case "A":   //  Active
                sStatusNeeded = "Active";
                break;
            case "I":   //  Inactive
                sStatusNeeded = "Inactive";
                break;
            case "T":    //  Terminated
                sStatusNeeded = "Terminated";
                break;
            default:
                Response.Redirect("~/UserNotAuthorized.aspx");
                break;
        }
        switch (Convert.ToString(Session["UserDataProfile"]))
        {
            case "Enterprise":
                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Account", sqlcon))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
                        cmd.Parameters.Add(new SqlParameter("@Account", Convert.ToInt32(Session["UserAccount"])));
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);
                            return dt;
                        }
                    }
                }
            case "Company":
                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Company", sqlcon))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
                        cmd.Parameters.Add(new SqlParameter("@Company", Convert.ToInt32(Session["UserCompany"])));
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);
                            return dt;
                        }
                    }
                }
            case "Office":
                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
                {
                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Office", sqlcon))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
                        cmd.Parameters.Add(new SqlParameter("@Office", Convert.ToInt32(Session["UserOffice"])));
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(dt);
                            return dt;
                        }
                    }
                }
            case "Agent":
                Response.Redirect("~/UserNotAuthorized.aspx");
                break;
        }
        return dt;
}
 
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    RadGrid1.DataSource = GetDataTable();
}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Feb 2014, 04:41 AM
Hi Lynn,

Please try to create the entire RadGrid from code behind. You can take a look at this documentation to know more on Creating a RadGrid Programmatically. When generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set. From your code i see that you have set before. Please try to make the necessary changes and see if it helps.

Thanks,
Princy
0
Lynn
Top achievements
Rank 2
answered on 19 Feb 2014, 01:54 PM
Princy,

I appreciate the assistance, but unfortunately that didn't work -- unless I messed it up somehow.  The modified code behind file is included below.  There were no changes made to the .aspx file.  The results were still identical to the earlier screen capture so I didn't take another.

Any other ideas?

​
001.protected void Page_Init(object sender, System.EventArgs e)
002.{
003.    if (!Page.IsPostBack)
004.    {
005.        sType = Request["T"];
006.        //  Get the users form security rules and set the buttons accordingly
007.        string sUserFormRules = Convert.ToString(Session["UserBrokerPlusFormsRules"]);
008.        string sRule = "";
009.        switch (sType)
010.        {
011.            case "A":   //  Active
012.                this.ListHeader.Text = "Active Agents";
013.                this.ListExplanation.Text = "Real estate agents presently working for your organization";
014.                sRule = sUserFormRules.Substring(21, 1);
015.                break;
016.            case "I":   //  Inactive
017.                this.ListHeader.Text = "Inactive Agents";
018.                this.ListExplanation.Text = "Real estate agents that are not working for your organization but are still on the roster";
019.                sRule = sUserFormRules.Substring(22, 1);
020.                break;
021.            case "T":    //  Terminated
022.                this.ListHeader.Text = "Terminated Agents";
023.                this.ListExplanation.Text = "Real estate agents that worked for your organization in the past";
024.                sRule = sUserFormRules.Substring(23, 1);
025.                break;
026.            default:
027.                Response.Redirect("~/UserNotAuthorized.aspx");
028.                break;
029.        }
030.        switch (sRule)
031.        {
032.            case "0":
033.                //  the user is not authorized for this page, so send them to the error page
034.                Response.Redirect("~/UserNotAuthorized.aspx");
035.                break;
036.            case "1":
037.                //  The user is only authorized for read-only activities, so set the buttons accordingly
038.                this.CreateNew.Enabled = false;
039.                break;
040.            case "2":
041.                //  The user is authorized to update data, so leave the buttons as is
042.                break;
043.        }
044. 
045.        this.RadGrid1.AllowFilteringByColumn = true;
046.        GridHyperLinkColumn hypercolumn = null;
047.        GridBoundColumn boundcolumn = null;
048. 
049.        //GridBoundColumn boundColumn;
050.        //boundColumn = new GridBoundColumn();
051.        //boundColumn.DataField = "CustomerID";
052.        //boundColumn.HeaderText = "CustomerID";
053.        //RadGrid1.MasterTableView.Columns.Add(boundColumn);
054.        //boundColumn = new GridBoundColumn();
055.        //boundColumn.DataField = "ContactName";
056.        //boundColumn.HeaderText = "Contact Name";
057.        //RadGrid1.MasterTableView.Columns.Add(boundColumn);
058. 
059.        hypercolumn = new GridHyperLinkColumn();
060.        hypercolumn.HeaderText = "Edit";
061.        hypercolumn.UniqueName = "Agent";
062.        hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/pencil_16.png\" />";
063.        hypercolumn.DataNavigateUrlFields = new string[] { "Agent" };
064.        hypercolumn.DataNavigateUrlFormatString = "OfcAgentEdit.aspx?M=Y&T=" + sType + "K=" + "{" + "0" + "}";
065.        hypercolumn.AllowFiltering = false;
066.        hypercolumn.HeaderStyle.Width = Unit.Pixel(50);
067.        hypercolumn.Exportable = false;
068.        this.RadGrid1.MasterTableView.Columns.Add(hypercolumn);
069. 
070.        hypercolumn = new GridHyperLinkColumn();
071.        hypercolumn.HeaderText = "Email";
072.        hypercolumn.UniqueName = "SendAgentMail";
073.        hypercolumn.Text = "<img border=\"0\" alt=\"View\" src=\"../Icons/mailIcon.gif\" />";
074.        hypercolumn.DataNavigateUrlFields = new string[] { "AgentEmail" };
075.        hypercolumn.DataNavigateUrlFormatString = "mailto:" + "{" + "0" + "}";
076.        hypercolumn.HeaderStyle.Width = Unit.Pixel(30);
077.        hypercolumn.AllowFiltering = false;
078.        hypercolumn.Exportable = false;
079.        this.RadGrid1.MasterTableView.Columns.Add(hypercolumn);
080. 
081.        boundcolumn = new GridBoundColumn();
082.        boundcolumn.UniqueName = "AgentID";
083.        boundcolumn.DataField = "AgentID";
084.        boundcolumn.HeaderText = "ID";
085.        boundcolumn.FilterControlWidth = Unit.Pixel(50);
086.        boundcolumn.HeaderStyle.CssClass = "mediumgridcol";
087.        boundcolumn.ItemStyle.CssClass = "mediumgridcol";
088.        boundcolumn.FooterStyle.CssClass = "mediumgridcol";
089.        boundcolumn.Visible = true;
090.        this.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
091. 
092.        boundcolumn = new GridBoundColumn();
093.        boundcolumn.UniqueName = "AgentFullName";
094.        boundcolumn.DataField = "AgentFullName";
095.        boundcolumn.HeaderText = "Name";
096.        boundcolumn.HeaderStyle.Width = Unit.Pixel(240);
097.        boundcolumn.FilterControlWidth = Unit.Pixel(100);
098.        boundcolumn.Visible = true;
099.        this.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
100. 
101.        //  this code is left here as a working example of displaying a short date in a RadGrid column
102.        //boundcolumn = new GridBoundColumn();
103.        //this.RadGrid1.Columns.Add(boundcolumn);
104.        //boundcolumn.UniqueName = "NewsEndDate";
105.        //boundcolumn.DataField = "NewsEndDate";
106.        //boundcolumn.HeaderText = "End";
107.        //boundcolumn.DataFormatString = "{0:MM/dd/yy}";
108.        //boundcolumn.Visible = true;
109.        //boundcolumn = null;
110. 
111.        boundcolumn = new GridBoundColumn();
112.        boundcolumn.UniqueName = "OfficeCommonName";
113.        boundcolumn.DataField = "OfficeCommonName";
114.        boundcolumn.HeaderText = "Office";
115.        boundcolumn.FilterControlWidth = Unit.Pixel(100);
116.        boundcolumn.HeaderStyle.CssClass = "largegridcol";
117.        boundcolumn.ItemStyle.CssClass = "largegridcol";
118.        boundcolumn.FooterStyle.CssClass = "largegridcol";
119.        boundcolumn.Visible = true;
120.        this.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
121. 
122.        boundcolumn = new GridBoundColumn();
123.        boundcolumn.UniqueName = "AgentCellular";
124.        boundcolumn.DataField = "AgentCellular";
125.        boundcolumn.HeaderText = "Cellular";
126.        boundcolumn.FilterControlWidth = Unit.Pixel(60);
127.        boundcolumn.HeaderStyle.CssClass = "smallgridcol";
128.        boundcolumn.ItemStyle.CssClass = "smallgridcol";
129.        boundcolumn.FooterStyle.CssClass = "smallgridcol";
130.        boundcolumn.Visible = true;
131.        this.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
132. 
133.        boundcolumn = new GridBoundColumn();
134.        boundcolumn.UniqueName = "AgentEmail";
135.        boundcolumn.DataField = "AgentEmail";
136.        boundcolumn.HeaderText = "Email";
137.        boundcolumn.HeaderStyle.CssClass = "smallgridcol";
138.        boundcolumn.ItemStyle.CssClass = "smallgridcol";
139.        boundcolumn.FooterStyle.CssClass = "smallgridcol";
140.        boundcolumn.Visible = true;
141.        boundcolumn.FilterControlWidth = Unit.Pixel(100);
142.        this.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
143. 
144.        RadGrid1.AllowPaging = Convert.ToBoolean(Session["ShowListsWithPaging"]);
145.        RadGrid1.PageSize = 20;
146.    }
147.    else
148.    {
149.        sType = Request["T"];
150.    }
151.}
152. 
153.protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
154.{
155.    //  this code is used to make filter columns visible/invisible as the grid grows/shrinks
156.    if (e.Item is GridFilteringItem)
157.    {
158.        GridFilteringItem Filter = (GridFilteringItem)e.Item;
159.        Filter["AgentID"].CssClass = "mediumgridcol";
160.        Filter["OfficeCommonName"].CssClass = "largegridcol";
161.        Filter["AgentCellular"].CssClass = "smallgridcol";
162.        Filter["AgentEmail"].CssClass = "smallgridcol";
163.    }
164.    ////  this code is left here for a working example of modifying column contents in a RadGrid
165.    //if (e.Item is GridDataItem)
166.    //{
167.    //    GridDataItem dataBoundItem = e.Item as GridDataItem;
168.    //    string strColumnValue1 = dataBoundItem["VendorShowInLists"].Text;
169.    //    if (strColumnValue1 == "0")
170.    //    {
171.    //        dataBoundItem["VendorShowInLists"].Text = "No";
172.    //    }
173.    //    else
174.    //    {
175.    //        dataBoundItem["VendorShowInLists"].Text = "Yes";
176.    //    }
177.    //}
178.}
179. 
180.protected void CreateNew_Click(object sender, EventArgs e)
181.{
182.    Response.Redirect("OfcAgentEdit.aspx?M=N&K=&T=" + sType);
183.}
184. 
185.public DataTable GetDataTable()
186.{
187.    String ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString;
188.    DataTable dt = new DataTable();
189.        string sStatusNeeded = "";
190.        switch (sType)
191.        {
192.            case "A":   //  Active
193.                sStatusNeeded = "Active";
194.                break;
195.            case "I":   //  Inactive
196.                sStatusNeeded = "Inactive";
197.                break;
198.            case "T":    //  Terminated
199.                sStatusNeeded = "Terminated";
200.                break;
201.            default:
202.                Response.Redirect("~/UserNotAuthorized.aspx");
203.                break;
204.        }
205.        switch (Convert.ToString(Session["UserDataProfile"]))
206.        {
207.            case "Enterprise":
208.                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
209.                {
210.                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Account", sqlcon))
211.                    {
212.                        cmd.CommandType = CommandType.StoredProcedure;
213.                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
214.                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
215.                        cmd.Parameters.Add(new SqlParameter("@Account", Convert.ToInt32(Session["UserAccount"])));
216.                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
217.                        {
218.                            da.Fill(dt);
219.                            return dt;
220.                        }
221.                    }
222.                }
223.            case "Company":
224.                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
225.                {
226.                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Company", sqlcon))
227.                    {
228.                        cmd.CommandType = CommandType.StoredProcedure;
229.                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
230.                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
231.                        cmd.Parameters.Add(new SqlParameter("@Company", Convert.ToInt32(Session["UserCompany"])));
232.                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
233.                        {
234.                            da.Fill(dt);
235.                            return dt;
236.                        }
237.                    }
238.                }
239.            case "Office":
240.                using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["BrokerPlus"].ConnectionString))
241.                {
242.                    using (SqlCommand cmd = new SqlCommand("Agents_GetAllByAgentType_And_Office", sqlcon))
243.                    {
244.                        cmd.CommandType = CommandType.StoredProcedure;
245.                        cmd.Parameters.Add(new SqlParameter("@AgentStatus", sStatusNeeded));
246.                        cmd.Parameters.Add(new SqlParameter("@AgentRecType", "Agent"));
247.                        cmd.Parameters.Add(new SqlParameter("@Office", Convert.ToInt32(Session["UserOffice"])));
248.                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
249.                        {
250.                            da.Fill(dt);
251.                            return dt;
252.                        }
253.                    }
254.                }
255.            case "Agent":
256.                Response.Redirect("~/UserNotAuthorized.aspx");
257.                break;
258.        }
259.        return dt;
260.}
261. 
262.protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
263.{
264.    RadGrid1.DataSource = GetDataTable();
265.}
0
Lynn
Top achievements
Rank 2
answered on 20 Feb 2014, 02:57 AM
Princy,

I have resolved this item. I thought I had upgraded this project to the latest release...and I was wrong.  Sorry to have taken your time.  It appears that the problem is caused by having installed a new release of your products but not upgrading this project.  I thought I had.  When I ran the upgrade and tested the project, the subject grid is working as it should.

Please close this one out.  Again, sorry to have taken your time!
Tags
Grid
Asked by
Lynn
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Lynn
Top achievements
Rank 2
Share this question
or