Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
132 views

I have a simple page where I am dynamically generating columns on the page load event and seting datasource during the need data source event.  The initial load works correctly, but after any postback the columns still exist but the header text and datafield properties are empty.

Below is the simpliest example I can make. Any thoughts on why the columns are losing their information?

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
    public class DataClass
    {
        private string _a = "";
        private string _b = "";
        public string A { get { return this._a; } }
        public string B { get { return this._b; } }
    }  
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            System.Reflection.PropertyInfo[] fields = typeof(DataClass).GetProperties();
            foreach (System.Reflection.PropertyInfo field in fields)
            {
                GridBoundColumn c = new GridBoundColumn();
                c.DataField = field.Name;
                c.HeaderText = field.Name;
                this.RadGrid1.MasterTableView.Columns.Add(c);
            }
        }
    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        System.Collections.Generic.List<DataClass> results = new System.Collections.Generic.List<DataClass>();
        this.RadGrid1.DataSource = results;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        // Column exist but header text and data field properties are ""
    }   
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Force Postback" onclick="Button1_Click" />       
        <telerik:RadGrid ID="RadGrid1" runat="server" onneeddatasource="RadGrid1_NeedDataSource" AutoGenerateColumns="false" />
    </form>
</body>
</html>
Shinu
Top achievements
Rank 2
 answered on 08 Jul 2008
1 answer
100 views
I've trying to embed the file browser demo in a aspx file that has a master page.

Until now everything works file, except from the following code in the Script.js file:

    Directories.GetFilesAndFolders(sender.get_selectedNode().get_value(), updateGrid);

I'm getting the follwing js error:

Line:  11
Char: 5
Error: 'Directories' is undefined
Code: 0

Any idea?
Vlad
Telerik team
 answered on 08 Jul 2008
2 answers
195 views
I have a RadGrid where after clicking "edit" I get the infamous "Object reference not set to an instance of an object" error.

I am using LinqDataSource that has EnableUpdate="true"

Here is the Grid source:

<telerik:RadGrid ID="rgProducts" runat="server"   
    AllowFilteringByColumn="True" DataSourceID="ldsProducts" 
    AllowPaging="True" AllowSorting="True" Skin="Vista" PageSize="20" 
    oncancelcommand="rgProducts_CancelCommand" Width="99%" 
    oneditcommand="rgProducts_EditCommand" OnItemDataBound="rgProducts_ItemDataBound" 
    onupdatecommand="rgProducts_UpdateCommand" AutoGenerateColumns="False" > 
      
    <PagerStyle Height="28px" Mode="NextPrevAndNumeric" Position="Bottom"/>  
      
    <mastertableview allowfilteringbycolumn="True" allowpaging="True" DataKeyNames="ProductId"   
        allowsorting="True" TableLayout="Fixed" DataSourceID="ldsProducts">  
      
        <Columns> 
            <telerik:GridEditCommandColumn> 
                <HeaderStyle Width="5%" /> 
            </telerik:GridEditCommandColumn> 
            <telerik:GridBoundColumn DataField="ProductId" DataType="System.Int32"   
                HeaderText="Id" ReadOnly="True" SortExpression="ProductId"   
                UniqueName="ProductId">  
                <HeaderStyle Width="15%" /> 
            </telerik:GridBoundColumn> 
            <telerik:GridTemplateColumn HeaderText="Type" SortExpression="ProductType.ProductTypeName" CurrentFilterFunction="Contains" AutoPostBackOnFilter="True" > 
                <ItemTemplate> 
                    <%#Eval("ProductType.ProductTypeName")%> 
                </ItemTemplate> 
                <HeaderStyle Width="30%" /> 
                <ItemStyle Wrap="false" /> 
            </telerik:GridTemplateColumn> 
            <telerik:GridBoundColumn DataField="ProComProductCode"   
                HeaderText="Product Code" SortExpression="ProComProductCode"   
                UniqueName="ProComProductCode" CurrentFilterFunction="Contains" AutoPostBackOnFilter="True">  
                <HeaderStyle Width="15%" /> 
                <ItemStyle Wrap="false" /> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="ProductName" HeaderText="Name"   
                SortExpression="ProductName" UniqueName="ProductName" CurrentFilterFunction="Contains" AutoPostBackOnFilter="True">  
                <HeaderStyle Width="35%" /> 
                <ItemStyle Wrap="false" /> 
            </telerik:GridBoundColumn> 
        </Columns> 
          
        <editformsettings editformtype="Template">  
            <formtemplate> 
                <!-- left this code out - very large --> 
            </formtemplate> 
            <popupsettings scrollbars="None" /> 
        </editformsettings> 
 
    </mastertableview> 
</telerik:RadGrid> 

When I set a breakpoint in the EditCommand event, the one line of code there that is hiding the edit column works just fine, then the code never reaches the breakpoint I have in the ItemDataBound event.  ANy ideas what could be happenning between these two events?  I tried stepping through beyond the EditCommandEvent, but it was stepping through the LINQ designer code.

Thoughts?

Michael
Michael
Top achievements
Rank 1
 answered on 08 Jul 2008
2 answers
143 views
Hi

I have page which opens a PDF file as well have few text boxes and drop down combos for data Entry. PDF file is opening in a Frame.

Now on the page load i need to set the focus on first Combo box and which works fine if the frame does not have any PDF file to open.

So when there is a PDf file and it opens it then it lose Focus. I reckon because the PDF file takes time to load. Still the cursor goes to the combo box but then disappear.


Can any one please help me regarding this.

Thanks in Advance
Ricky
Ricky
Top achievements
Rank 2
 answered on 07 Jul 2008
2 answers
129 views
Hi there...

Quick question... My RadGrids are expanding to fill up the width of the page.  Even if I set the column widths.  How do I turn off the autosizing and get them to stick to the column widths?

Thx,
Justin


Justin Jones
Top achievements
Rank 1
 answered on 07 Jul 2008
8 answers
230 views

I have a detail table in my grid and I want to allow paging on it but it is not working. I currently have 12 records in y dataset and I have the page size set at ten, but it will only show me the first ten records and will not show me page 2 at all.  If I set the page size at 2, the detail table will show only 2 records and will not page to any other page. If I set the pagesize to 20 it will show all 12 records, but then I will only be able to see the first 20 records.  Basically it is not allowing me to see past the first page in the detail table.  

Does anyone know what would be causing this behavior?  What would be the correct pager settings for both the master table and the detail tables?   

ranro
Top achievements
Rank 1
 answered on 07 Jul 2008
1 answer
94 views
I am working on exporting a grid in a hierarchical mode to excel. I have 3 levels.

My issue is when I export I can't seem to get the columns to align to the left. When I export the columns appear to be centered. To fix this I thought adding HorizonalAlign="Left" to the table declarations would fix this. It did work to a degree. The 2 level still center aligns the items and when the web page is displayed (using Office 2007 skin) it breaks the CSS styling on the Headers of the DetailTables.

As I was typing my post I had an idea to try putting the <ItemStyle HorizontalAlign="Left" /> directly into the GridBoundColumn. This worked to left align my items.

Is there a difference between putting this <ItemStyle HorizontalAlign="Left" /> as a global declaration or as a per column declaration?  I thought they would be the same. I suspect there may be a bug if not.

I am using release Q3 2007.
Karl
Top achievements
Rank 1
 answered on 07 Jul 2008
1 answer
112 views
I am trying to align my items to the left programatically after a button is clicked, then I plan to export them.

I have been trying several methods but I can't seem to get them to move unless I hard code it on my page. Does anyone have any insight into when I should be setting this property so that it will be seen in the export? and any preferred methods to set it?
Karl
Top achievements
Rank 1
 answered on 07 Jul 2008
1 answer
98 views
Hi,

I need some help to use Image Manager. I have used this topics to link image manager in multiple instances in the same form. 

http://www.telerik.com/community/forums/thread/b311D-beaabh.aspx

In this topic, I create one Textbox with the returned getUrl() in the ImageCaller UserControl. The returned value is in the usercontrol as Text.Id. I have tested this but is not working for me case. I need to return the value in one ITextControl defined in the parent page not in the Usercontrol that call the image manager. Could you help me to implement the image Manager that take the Textbox.ID ClientID from parent page and send the returned value to this parent page.

My pagent page implement one ITextControl linked to metafields stored as Shorttext ID="Image2" in cms. I need to paste the getpath() returned from ImageManager to link my database.

parent aspx page in cms
<li class="selector">  
<asp:Label ID="Label12" AssociatedControlID="Image2" runat="server">  
<asp:Literal ID="Literal14" runat="server" Text="IMAGE2"></asp:Literal> 
<em id="Em5" runat="server"></em></asp:Label> 
<asp:TextBox ID="Image2" Text="" runat="server" MaxLength="250"></asp:TextBox> 
<im:ImageCaller ID="ImageCaller2" runat="server" /> 
<p class="example">  
<asp:Literal ID="Literal15" runat="server" Text="Using Image Manager"></asp:Literal></p>  
</li> 
 The Image2.ID is my Client ID. 

Thanks
Pierre
Top achievements
Rank 1
 answered on 07 Jul 2008
0 answers
122 views
Hi everybody,
I'm developing scheduler application, and i use RadScheduler for project, but now I want to use Web service (asmx) to binding data in RadScheduler, and I want when customer have any change on RadScheduler then it auto Update in database.
And I using LINQ to SQL get data for Webservice.
Who can give me any solution, please help me....I'm thnks so much!!!!
hongnguyenx
Top achievements
Rank 1
 asked on 07 Jul 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?