Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
96 views
Hello,

I have a form with a RadScriptManger, RadAjaxManager, and RadGrid.

One of the columns of the RadGrid loads a dynamic linkbutton that I want to pop-up an Open/Save File Dialogue box.  It works without the RadAjaxManager, but with it I get this error:

Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Which is correct, I subscribe each dynamic link button to the following click event that modifies the Response,
Protected Sub onClick(ByVal sender As Object, ByVal e As EventArgs)
  
        Try
  
            Dim NewButton As LinkButton = CType(sender, LinkButton)
  
            Dim con As New SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("NBOConnectionString").ConnectionString)
            Dim cmd As New SqlClient.SqlCommand("Select Id, NDAId, FileName, [File], FileType FROM NDA_Files Where Id = " & Convert.ToInt32(NewButton.ToolTip), con)
            Dim da As New SqlClient.SqlDataAdapter(cmd)
  
            con.Open()
  
            Dim dt As New Data.DataTable
  
            da.Fill(dt)
  
            For Each row As Data.DataRow In dt.Rows
                With row
  
                    Dim DataFile() As Byte
                    DataFile = .Item("File")
                    HttpContext.Current.Response.Buffer = True
                    HttpContext.Current.Response.ContentType = .Item("FileType")
                    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" & .Item("FileName"))
                    HttpContext.Current.Response.AppendHeader("Content-Length", DataFile.Length.ToString())
                    HttpContext.Current.Response.BinaryWrite(DataFile)
  
                End With
            Next
                    Catc

I searched around and found this article:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx

Towards the bottom of that, there is this solution:
Call ScriptManager.RegisterPostBackControl() and pass in the button in question. This is the best solution for controls that are added dynamically, such as those inside a repeating template.

I didn't see "RegisterPostBackControl()" within the RadScriptManager so I added .NETs script manager and added a section in my RadGridItemDataBound procedure to add the dynamic linkbuttons to this as show below:
For Each Control In e.Item.Controls
                       If CType(Control, Telerik.Web.UI.GridTableCell).Controls.Count > 2 Then
                           If CType(Control, Telerik.Web.UI.GridTableCell).Controls(1).GetType.Name = "LinkButton" Then
                               Dim lnkButton As LinkButton = CType(CType(Control, Telerik.Web.UI.GridTableCell).Controls(1), LinkButton)
                               ScriptManager1.RegisterPostBackControl(lnkButton)
                           End If
                       End If
                   Next

Which finds the LinkButtons and adds them with no errors.....However when I click the linkbutton I still get the error.
Is there any better way to get this functionality?

Either I need to figure out how to exclude the linkbuttons from the AJAX call, or a way to make the pop-up work without using the Response.  Any Ideas?

Thanks,

Coty



Pavlina
Telerik team
 answered on 10 Feb 2011
4 answers
156 views
Hi

I need to set overflow: visible on a textbox but have found that the style is not being obeyed.

I modified a Telerik example page by adding a textbox to the page with the overflow property set:

<li>
      test : <input type="text" value="message" style="overflow:visible;width:20px" />
</li>

I have attached a screenshot of what I see.

I am using RadControls for ASP.NET AJAX Q3 2010 and I see the problem in IE8 and FireFox 3.6.

Any help is appreciated.
TheCroc
Top achievements
Rank 1
 answered on 10 Feb 2011
1 answer
107 views
I am using date range filter from this example

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx it has 2  datepickers for From and To.

I want to add also regular filter or date picker fo this column too.Otherwise, how do i filter just the date not date range?
Just found this post
http://www.telerik.com/community/forums/aspnet-ajax/grid/filter-with-from-and-todate-for-datetime-colum-with-normal-datepicker-filter.aspx

Dont think it provides elegant solution


Thank

Alex
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
1 answer
149 views
When using RadGrid's WebUserControl, the DataItem object becomes null when using an ObjectDataSource only to fill ListBox.

Scenario 1 Works - Calling DataSource = __ and DataBind() in Page_Load:

protected void Page_Load(object sender, EventArgs e)  
{
    lstItemCollection.DataSource = GetCityCollection();
    lstItemCollection.DataBind();
}
public IEnumerable<Customer> GetCityCollection()
{
    using (UowEntities uow = new UowEntities())
    {
        CustomerRepository cr = new CustomerRepository(uow);
        return cr.SelectAll().ToArray();
    }
}
<asp:ListBox ID="lstItemCollection" runat="server" SelectionMode="Multiple" 
    DataValueField="CustomerId" DataTextField="City"  />

Scenario 2 - DataItem object is null when needed if using ObjectDataSource to bind data to ListBox:

<asp:ListBox ID="lstItemCollection" runat="server" SelectionMode="Multiple" DataValueField="CustomerId" DataTextField="City" DataSourceID="odsCityCollection" />           
<asp:ObjectDataSource ID="odsCityCollection" runat="server" SelectMethod="GetCityCollection"
TypeName="LINQScratchPad.Web.CommonUserControls.CustomerControl" ></asp:ObjectDataSource>

The ObjectDataSource automatically calls the GetCityCollection() method and that is when the DataItem becomes null. Later in the page lifecycle it will have a value again until I force the ListBox to DataBind in attempt to see if I have a value to DataItem (or even access to a HiddenField for that matter!).  I want the CustomerId value to filter my query in the SelectMethod of the ObjectDataSource. **NOTE: this is a very simple example and not real-world as I have moved to a play project for testing to resolve the underlying issue of a null DataItem.** I added the PreRender event handlers to show I have access to the DataItem again after it had become null.

public partial class CustomerControl : System.Web.UI.UserControl
{
    private object _dataItem;
    public object DataItem
    {
        get { return this._dataItem; }
        set { this._dataItem = value; }
    
    protected void Page_Load(object sender, EventArgs e)  {  }

    public IEnumerable<Customer> GetCityCollection()
    {
        using (UowEntities uow = new UowEntities())
        {
            Customer foo = (Customer)DataItem; // Always null!
              
            // Will throw null reference exception here if uncommented
            //var bar = HiddenField1.Value; 
            CustomerRepository cr = new CustomerRepository(uow);
            return cr.SelectAll().ToArray();
        }
    }
      
    protected void Page_PreRender(object sender, EventArgs e)
    {
        Customer foo = (Customer)DataItem; // Has value here
        var bar = this.HiddenField1.Value; // Has value here
        lstItemCollection.DataBind(); // DataItem is now null again :(
    }
    protected override void OnPreRender(EventArgs e)
    {
        Customer foo = (Customer)DataItem; // Has value here
        var bar = this.HiddenField1.Value; // Has value here
        lstItemCollection.DataBind(); // DataItem is now null again :(
        base.OnPreRender(e);
    }
}

In watching the DataItem value throughout the page lifecycle process, this is what I observed:
Page_Load - DataItem has value.  {F10}
Sets my HiddenField value. {F10}
<asp:HiddenField Value='<%# Eval("CustomerId") %>'  ID="HiddenField1" runat="server" />
Sets my other two Binds. {F10}
<ol class="column1">
    <li>
        <asp:Label ID="lblFirstName" runat="server">First Name:</asp:Label>
        <asp:TextBox ID="txtFirstName" runat="server"  Text='<%# Bind("FirstName") %>' />
    </li>
    <li>
        <asp:Label ID="lblLastName" runat="server">Last Name: </asp:Label>
        <asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>' />
    </li>
</ol>
ObjectDataSource calls GetCityCollection() and now DataItem object is null.

After that when stepping into the PreRender the DataItem has a value again until calling ListBox.DataBind() where the ObjectDataSource steps into the GetCityCollection() method and DataItem is once again null.

Can anybody explain why DataItem becomes null please?  
Thanks in advance!!
-Carrie
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
1 answer
110 views
hi
i have to disable editing a particular column in a radgrid how to do it (i.e)if i have five column in a grid i have to edit and update only 2 columns the other 3 should not be editable
Shinu
Top achievements
Rank 2
 answered on 10 Feb 2011
2 answers
120 views

I just wondered if there was a skin/CSS available to re-create something similar to the RadToolBar used on the Telerik demos site. It looks like it is a RadTabStrip but in fact is a RadToolBar; any help with re-creating something similar to this would be greatly appreciated! I have attached a screen shot of what I am referring to if I haven’t been that clear.

James
Top achievements
Rank 1
 answered on 10 Feb 2011
3 answers
103 views
I've searched and looked up on how to hide Expand/Collapse but seems to only work if you already have all the data.
there a way to do it with ServerOnDemand loading? 

If I try this http://www.telerik.com/help/aspnet/grid/grdhideexpandcollapseimageswhennorecords.html
All the expand/collapse buttons go away. I'm assuming because the grid doesn't know if the row has child items or not. I have a dataset with three tables loaded already, there a way to check to see if each row will have child items and then hide/show the expand?
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
9 answers
444 views
As the title says my grid extends past the screen width....here is my Grid:
<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Sunset" AllowSorting="true" ShowFooter="false">  
                        <ItemStyle Font-Size="11px" /> 
                        <MasterTableView> 
                            <RowIndicatorColumn> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                            </ExpandCollapseColumn> 
                        </MasterTableView> 
                        <ClientSettings AllowColumnHide="false">  
                            <Scrolling AllowScroll="true" UseStaticHeaders="True" ScrollHeight="450px" /> 
                            <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" 
                                   /> 
                        </ClientSettings> 
                    </telerik:RadGrid> 
When the grid loads with data it stretches past the screen width.  What I want it to do is add  a scroll bar to the bottom of the grid and allow you to scroll left or right without going off the right side of the screen.  Kind of like how you can scroll up and down within the grid with the side scroll bar....that works as inteded.

I also set the initial size of my columns programmatically in the ColumnCreated event:
    Protected Sub RadGrid1_ColumnCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated  
 
        Dim name As String = e.Column.UniqueName  
 
        'resize columns  
        If name = "Name" Or name = "Address1" Or name = "RFI Email" Or name = "Personal Email" Or name = "Practice" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 150  
            boundColumn.HeaderStyle.Width = 150  
        End If 
        If name = "Initials" Or name = "State" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 45  
            boundColumn.HeaderStyle.Width = 45  
        End If 
        If name = "Office" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 80  
            boundColumn.HeaderStyle.Width = 80  
        End If 
        If name = "Ext" Or name = "Zip" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 50  
            boundColumn.HeaderStyle.Width = 50  
        End If 
        If name = "Cell" Or name = "Home" Or name = "Fax" Or name = "Business" Or name = "City" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 89  
            boundColumn.HeaderStyle.Width = 89  
        End If 
        If name = "Address2" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 70  
            boundColumn.HeaderStyle.Width = 70  
        End If 
        If name = "Preferred" Then 
            Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)  
            boundColumn.ItemStyle.Width = 95  
            boundColumn.HeaderStyle.Width = 95  
        End If 
 
    End Sub 

Any help is appreciated.
thanks,

Coty
Pavlina
Telerik team
 answered on 10 Feb 2011
4 answers
111 views
We have a RadGrid with an EditFormType of WebUserControl.

The problem is that the DataItem property is set to the correct element only on first selection. If, on save, validation error occurs and the form is redisplayed, the value passed to the DataItem is null.

What can we do wrong? Is there something specific to set to always get the correct element on each "postback"?

Thanks,

Hugues
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
11 answers
163 views
Hello,
I have a problem with collapsing radgrid items, when they're set to edit mode.

protected void Page_Load(object sender, EventArgs e)
{
 
      for (int i = 0; i < radGrid.PageSize; i++)
        {           
            for (int j = 0; j < radGrid.PageSize; j++)
            {
                radGrid.EditIndexes.Add(i, 0, j);
            }
        }
 
           
}

When I use javascript collapseItem() function, it's impossible to expand it later by user.

On the other hand, it's possible to collapse and expand items by user click - but again, not by running js onclick() method.

function CollapseAll() {
    var grid = $find("<%= radGrid.ClientID %>");
 
    master = grid.get_masterTableView();
 
    for (masterIndex = 0; masterIndex < master.get_dataItems().length; masterIndex++) {
 
            master.collapseItem(masterIndex);
    }

Any help would be appreciated.
Iana Tsolova
Telerik team
 answered on 10 Feb 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?