Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
273 views
I am attempting to load values in a RadComboBox inside a RadGrid and I am getting the following error -

"Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"

Here is the markup for the grid

<telerik:RadGrid runat="server" ID="rgrdClaimantStatus" 
    AutoGenerateColumns="False" 
    Skin="Windows7"  OnInt="InitializeGrid"
    Style="margin-top: 0px"
    OnNeedDataSource="rgrdClaimantStatus_NeedDataSource" 
    OnUpdateCommand="rgrdClaimantStatus_UpdateCommand"
    OnInsertCommand="rgrdClaimantStatus_InsertCommand" 
    OnDeleteCommand="rgrdClaimantStatus_DeleteCommand"
    OnItemCommand="rgrdClaimantStatus_ItemCommand"
    OnItemDataBound="rgrdClaimantStatus_ItemDataBound"   
    OnPreRender="rgrdClaimantStatus_PreRender" 
    OnItemCreated="rgrdClaimantStatus_ItemCreated"
    TabIndex="21"              
    >
    <MasterTableView commanditemdisplay="Top" EditMode="InPlace" ShowHeadersWhenNoRecords="True"> 
        <Columns>
            <telerik:GridButtonColumn CommandName="Delete" ButtonType="ImageButton" ImageUrl="~/PPSPortal/images/Cancel.gif" UniqueName="DeleteColumn" ShowInEditForm="True" />
            <telerik:GridTemplateColumn UniqueName="StatusDesc" DataField="StatusDesc" HeaderText="Status" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadComboBox runat="server" ID="rcbClaimantStatusCode" Width="100"  Text='<%# Bind("StatusDesc")  %>'  />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateFrom" DataField="DateFrom" HeaderText="Date From" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadDatePicker runat="server" ID="rdpClaimantStatusStartDate" width="150" DbSelectedDate='<%# Bind("DateFrom") %>'>
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
                        <DateInput DisplayDateFormat="M/d/yyyy" DateFormat="M/d/yyyy" TabIndex="2" />
                        <DatePopupButton ImageUrl="" HoverImageUrl="" TabIndex="2"></DatePopupButton>
                    </telerik:RadDatePicker> 
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateTo" DataField="DateTo" HeaderText="Date To" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                    <telerik:RadDatePicker runat="server" ID="rdpClaimantEndDate" width="150" onkeydown="ClaimantStatusEndDateKeyDown(this, event)" DbSelectedDate='<%# Bind("DateTo")  %>'>
                        <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
                        <DateInput DisplayDateFormat="M/d/yyyy" DateFormat="M/d/yyyy" TabIndex="2" />
                        <DatePopupButton ImageUrl="" HoverImageUrl="" TabIndex="2"></DatePopupButton>
                    </telerik:RadDatePicker> 
                </ItemTemplate>                
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn UniqueName="DateCreated" DataField="DateCreated" HeaderText="Date Created" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantDateCreated" Width="150" Text='<%# Bind("DateCreated")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>                                                            
            <telerik:GridTemplateColumn UniqueName="DateEdited" DataField="DateEdited" HeaderText="Date Edited" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantDateEdited" Width="150" Text='<%# Bind("DateEdited")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>            
            <telerik:GridTemplateColumn UniqueName="ModifiedBy" DataField="ModifiedBy" HeaderText="Modified By" FooterStyle-Font-Bold="true" FooterStyle-Wrap="false" ItemStyle-Wrap="false">
                <ItemTemplate>                                       
                     <asp:Label runat="server" ID="lblClaimantModifiedBy" Width="150" Text='<%# Bind("ModifiedBy")  %>' />
                </ItemTemplate>                
            </telerik:GridTemplateColumn>                                                                      
        </Columns>
    </MasterTableView>
    <ClientSettings>              
        <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
        <DataBinding EnableCaching="True" />
        <ClientEvents OnKeyPress="KeyPressed" />
    </ClientSettings>               
</telerik:RadGrid>

and here is the code that is binding the combo box

protected void rgrdClaimantStatus_ItemDataBound(object source, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        //SetEditModeColumnWidths(e.Item as GridDataItem);
        RadComboBox status = ((e.Item as GridDataItem)["StatusDesc"].FindControl("rcbClaimantStatusCode") as RadComboBox);
        LoadClaimantStatusList(status, Convert.ToInt32((GetSelectedCompany())));
      
    }
}

protected void LoadClaimantStatusList(RadComboBox rddlStatus, int companyId)
{
    ReferenceProcess rc = new ReferenceProcess();
    Dictionary<int,string> statusList = rc.GetClaimantStatusList(CentralDBConnString, companyId);
    rddlStatus.DataSource = statusList;
    rddlStatus.DataTextField = "Value";
    rddlStatus.DataValueField = "Key";
    rddlStatus.DataBind();
    rddlStatus.Items.Insert(0, new RadComboBoxItem("Select a status", string.Empty));
}

I had read in other threads about removing the DataBind() from the above code, but all that does is allow the load of the "Select A Status" item and none of the database items.

Thanks!
Nencho
Telerik team
 answered on 22 Oct 2012
6 answers
109 views
Hi,

Is it possible to Drag n drop multiple appointments across resources( using resource grouping) In Asp.Net Ajax Scheduler (Latest version or any ?)
Ravi
Top achievements
Rank 1
 answered on 22 Oct 2012
3 answers
298 views
Hola buen dia me gustaria saber como puedo incluir en la lista de los temas que viene por default mi tema pesonalizado con el biulder espeor me puedan ayudar para que asi lo pueda aplicar de una forma mas sencilla y facil
Bozhidar
Telerik team
 answered on 22 Oct 2012
2 answers
135 views
I have used two Rad Tab in my form
1st tab added some text field
2nd tab added Rad Grid. see my screen shot
Default row 5 is set then i have add row using addrow button to click.
When i click Add Row button to row create but previous row clear

This is my addrow coding:
private void addrow(int currow)//int currow
        {
            object[] emptyRow = new object[columcount];
            tabledata1 = null;
            DataTable dt = tabledata1;
            assigndt2(dt);
            dt.Rows.Add(emptyRow);
            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }

private void assigndt2(DataTable dt)
        {
            RadComboBox r1;
            RadNumericTextBox rn1;

            for (int i = 0; i <= RadGrid1.Items.Count - 1; i++)
            {
                if (dt.Rows.Count - 1 < i)
                {
                    object[] emptyRow = new object[columcount];
                    dt.Rows.Add(emptyRow);
                }
                r1 = (RadComboBox)this.RadGrid1.Items[i].FindControl("Workdesc");
                dt.Rows[i]["Workdesc"] = r1.Text;
                r1 = (RadComboBox)this.RadGrid1.Items[i].FindControl("Radcombo_Unit");
                dt.Rows[i]["Radcombo_Unit"] = r1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Quantity");
                dt.Rows[i]["Quantity"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Rate");
                dt.Rows[i]["Rate"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Amount");
                dt.Rows[i]["Amount"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Fees");
                dt.Rows[i]["Fees"] = rn1.Text;
                rn1 = (RadNumericTextBox)this.RadGrid1.Items[i].FindControl("Total");
                dt.Rows[i]["Total"] = rn1.Text;


            }

        }
Tamim
Top achievements
Rank 1
 answered on 22 Oct 2012
1 answer
137 views
I'm having a logic issue.  I have some Comboboxes that I need to cascade while in Edit or Insert Mode.  The problem is when I Bind the second Combo based on the first, the entire Grid does a PostBack and so the Combos rebind again.

I know i'm likely just missing an 'If Postback' or something, but my brain is mush right now.

 

<telerik:RadGrid ID="RecipientsGrid" runat="server" AutoGenerateColumns="false" EnableViewState="true" PageSize="5" AllowFilteringByColumn="true" AllowPaging="true" AllowSorting="True">

<EditFormSettings EditFormType="Template">

<FormTemplate>

<telerik:RadComboBox ID="CountryCombo" runat="server">

 

</telerik:RadComboBox>

<telerik:RadComboBox ID="ProvinceCombo" runat="server" Width="325" >

</telerik:RadComboBox>

</FormTemplate>

</EditFormSettings>

</telerik:RadGrid>


    Private Sub RecipientsGrid_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemDataBound
 
        If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
            Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim ProvinceCombo As RadComboBox = TryCast(editItem.FindControl("ProvinceCombo"), RadComboBox)
            Dim CountryCombo As RadComboBox = TryCast(editItem.FindControl("CountryCombo"), RadComboBox)
            Dim CityCombo As RadComboBox = TryCast(editItem.FindControl("CityCombo"), RadComboBox)
            '** Populate ComboBoxes and define their Default Value
            Using context As New DataEntities
                With CountryCombo
                    .DataValueField = "CountryId"
                    .DataTextField = "CountryName"
                    .DataSource = context.Countries.OrderBy(Function(x) x.displayOrder).ToList
                End With
                CountryCombo.Width = Unit.Pixel(320)
                CountryCombo.DataBind()
            End Using
 
            Using context As New DataEntities
                With ProvinceCombo
                    .DataValueField = "ProvinceId"
                    .DataTextField = "NameEnglish"
                    .DataSource = context.Provinces.Where(Function(x) x.CountryId = CountryId).OrderBy(Function(x) x.NameEnglish).ToList
 
                End With
                ProvinceCombo.Width = Unit.Pixel(320)
                ProvinceCombo.DataBind()
            End Using
 
 
            Using context As New DataEntities
                With CityCombo
                    .DataValueField = "CityId"
                    .DataTextField = "CityName"
                    .DataSource = context.Cities.Where(Function(x) x.ProvinceID = ProvinceId).OrderBy(Function(x) x.CityName).ToList
                End With
                CityCombo.Width = Unit.Pixel(320)
                CityCombo.DataBind()
            End Using
            SetComboBoxDefault(CountryId, CountryCombo, "Country")
            SetComboBoxDefault(ProvinceId, ProvinceCombo, "Province/State")
            SetComboBoxDefault(CityId, CityCombo, "City")
 
 
        End If
 
 
    End Sub
 
    Public Sub SetComboBoxDefault(ByVal FindItemByValue As Integer, ByVal Control As RadComboBox, ByVal DisplayText As String)
 
        Dim ComboBoxItem As RadComboBoxItem
 
        If FindItemByValue >0 Then
            ComboBoxItem = Control.FindItemByValue(FindItemByValue)
            ComboBoxItem.Selected = True
 
        Else
            Control.Items.Insert(0, New RadComboBoxItem("-- Please select a " & DisplayText & " --", String.Empty))
        End If
 
    End Sub
 
    Private Sub RecipientsGrid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RecipientsGrid.ItemCreated
If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
 
            'if the item is in edit mode
            Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim CountryCombo As RadComboBox = DirectCast(editItem.FindControl("CountryCombo"), RadComboBox)
            CountryCombo.AutoPostBack = True
 
            AddHandler CountryCombo.SelectedIndexChanged, AddressOf CountryCombo_SelectedIndexChanged
 
        End If
 
 
    End Sub
 
    Protected Sub CountryCombo_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
 
        If RecipientsGrid.MasterTableView.IsItemInserted <> False Then
 
            Dim insertItem As GridEditFormInsertItem = DirectCast(TryCast(sender, DropDownList).NamingContainer, GridEditFormInsertItem)
 
            Dim ddlList As DropDownList = DirectCast(insertItem.FindControl("Dropdownlist2"), DropDownList)
        Else
 
            Dim CountryCombo As RadComboBox = DirectCast(sender, RadComboBox)
            Dim editedItem As GridEditableItem = DirectCast(TryCast(sender, RadComboBox).NamingContainer, GridEditableItem)
            Dim ProvinceCombo As RadComboBox = DirectCast(editedItem.FindControl("ProvinceCombo"), RadComboBox)
 
            Using context As New DataEntities
                With ProvinceCombo
                    .DataValueField = "ProvinceId"
                    .DataTextField = "NameEnglish"
                    .DataSource = context.Provinces.Where(Function(x) x.CountryId = e.Value).OrderBy(Function(x) x.NameEnglish).ToList
                End With
                ProvinceCombo.Width = Unit.Pixel(320)
                ProvinceCombo.DataBind()
            End Using
 
        End If
 
    End Sub





Tsvetoslav
Telerik team
 answered on 22 Oct 2012
4 answers
163 views
I used radgrid view for display some of my data and using that rad view. I need to do two things
1. delete some records - need ajax manager
2. stream to web browser - need to disable ajax manager.

here is my code snipts 

<script type="text/javascript">
            function requestStart(sender, args) {
                if (args.get_eventTarget().indexOf("GD") > 0)
                    args.set_enableAjax(false);
            }
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="requestStart">

in the grid
<%--<telerik:GridButtonColumn ButtonType="LinkButton" Text="<img src='../App_Themes/default/images/genDoc.gif' border='0' title='Generate Document'/>" UniqueName="GD" CommandName="G"></telerik:GridButtonColumn>--%>


<telerik:GridTemplateColumn HeaderText="" UniqueName="Image">
<ItemTemplate>
<asp:ImageButton ID="GD" runat="server" ImageUrl="~/App_Themes/Default/images/genDoc.gif" CommandName="1" OnClick="ImageButton1_Click">
</
asp:ImageButton>         
</
ItemTemplate><br></telerik:GridTemplateColumn>

in the code behind

  protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
          if (e.CommandName == "G")
            {
                genDoc(e.Item.ItemIndex);
            }
        }

        protected void ImageButton1_Click(object sender, EventArgs e)                   //method 2
        {
            genDoc(0);
        }

If I use the commented link button thing it will go to the method run method well but not give me download a file. 
If I use image button it works well and I can download a file, but I cant get particular index to my method(e.Item.ItemIndex
)...{in the genDoc() - document.Save("Sample.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment); }

any way what I want to pass e.Item.ItemIndex value to my method genDoc(int index)...Please help me. thanks

Shinu
Top achievements
Rank 2
 answered on 22 Oct 2012
3 answers
1.1K+ views
I'm having a hard time getting all of the column names for a tree list with javascript

I can call get_columns() and get an array of objects back, but they don't seem TreeListColumn objects - I can't call get_uniqueName() on them. I've dug around in the objects a bit in the debugger and I don't see the unique name in there at all.

Am I doing something wrong?
Princy
Top achievements
Rank 2
 answered on 22 Oct 2012
2 answers
583 views
Hi All,

           I am using RadAsyncUpload control in my program. I wanted to reduce the size of text box which comes with asyncupload control. Is it possible??? Here is my sample code.

<telerik:RadAsyncUpload runat="server" AllowedFileExtensions="jpg,png" ID="rdUploadImage" MultipleFileSelection="Disabled" MaxFileInputsCount="1" ControlObjectsVisibility="None" Width="1px" OnClientFileUploaded="ImageFileUploaded" InputSize="40" >
  <Localization Select="Browse" />
  </telerik:RadAsyncUpload>
  <style type="text/css">
  .RadUpload  .ruRemove 
  {
      display:none;
  }
  </style>

If anybody knows, kindly let me know the solution. Thanks in advance.
Geetha
Top achievements
Rank 1
 answered on 22 Oct 2012
1 answer
322 views
Hola,


      Hay alguna forma de globalizar el idioma de los controles al español?


Saludos.


Miguel Santiago
Kate
Telerik team
 answered on 22 Oct 2012
1 answer
87 views
Hi Is there one place I can go to find a list of enhancements to the rad Ajax controls since the Q2 2010 release. (As far as web development is concerned). I am trying to assess the benefit of upgrading to a more recent release for my business. Thanks Clive
Eyup
Telerik team
 answered on 22 Oct 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?