Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
111 views

Dear technology architects:

I need an expert voice to resolve my problem.
I have a RadGrid with AutoGeneratedColumns = "False", but I add programatically the columns.  There are BoundColumns and GridDropDownColumn.

The GridDropDownColumns are generated dynamically because I don't know how many columns will come from the grid datasource.  Then I have the following code in the Page_Load:

int ContCatalogos = 0;
RadGridSabana.MasterTableView.Columns.Clear();
foreach (DataColumn dataColumn in dtSabana.Columns)
{
 
 
        ContCatalogos++;
 
        switch (ContCatalogos)
        {
            case 1:
                dsCatalogos1.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos1.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 2:
                dsCatalogos2.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos2.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 3:
                dsCatalogos3.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos3.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 4:
                dsCatalogos4.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos4.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 5:
                dsCatalogos5.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos5.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 6:
                dsCatalogos6.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos6.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 7:
                dsCatalogos7.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos7.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 8:
                dsCatalogos8.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos8.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 9:
                dsCatalogos9.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos9.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 10:
                dsCatalogos10.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos10.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 11:
                dsCatalogos11.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos11.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 12:
                dsCatalogos12.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos12.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 13:
                dsCatalogos13.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos13.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 14:
                dsCatalogos14.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos14.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
            case 15:
                dsCatalogos15.SelectParameters[0].DefaultValue = "1";   //Empresa
                dsCatalogos15.SelectParameters[1].DefaultValue = dataColumn.ColumnName;   //Catalogo
                break;
        }
 
 
 
 
        GridDropDownColumn dropdownColumn = new GridDropDownColumn();
        this.RadGridSabana.MasterTableView.Columns.Add(dropdownColumn);
        dropdownColumn.DataField = dataColumn.ColumnName;    //Una columna del DataSource del grid.
        dropdownColumn.ListValueField = dataColumn.ColumnName;   //La columna de la funcion que trae los valores para llenar el combo.  Esta columna debe tener los mismos valores que Datafield para que se relacione.
        dropdownColumn.DataSourceID = "dsCatalogos" + ContCatalogos.ToString();   //El nombre del DataSource
        dropdownColumn.ListTextField = dataColumn.ColumnName;     //Es la columna del datasource del Combo que contiene el nombre a desplegar
        //dropdownColumn.UniqueName = dataColumn.ColumnName;
        dropdownColumn.HeaderText = dataColumn.ColumnName;
 
 
 
 
     
}


I have to create an independent ObjectDataSource for each GridDropDownColumn.  If I don't know how many columns could be retrieved I have to create more than 15  ObjectDataSourcse  manually in the code.
If the grid datasource contains more than 15 columns, I have a problem...

Following the code in the ASPX

<asp:ObjectDataSource ID="dsCatalogos1" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<asp:ObjectDataSource ID="dsCatalogos2" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<asp:ObjectDataSource ID="dsCatalogos3" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<asp:ObjectDataSource ID="dsCatalogos4" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<asp:ObjectDataSource ID="dsCatalogos5" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
 
<asp:ObjectDataSource ID="dsCatalogos6" runat="server"  TypeName="BusinessLayer.Funciones"
    SelectMethod="ConsultarItemsCatalogo"
    OldValuesParameterFormatString="original_{0}" >
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGridSabana" Name="Empresa"          PropertyName="SelectedValue" Type="Int32" />
        <asp:ControlParameter ControlID="RadGridSabana" Name="NombreCatalogo"   PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>

the DataSources are equal each other, the unique difference is the ID.  They call to the same function that receives the same parameters but with different values.
If you take a look in the code behind, I have to insert a switch instruction to give them the parameter values.

My question is:

Is there a way to do the same thing creating the ObjectDataSources dynamically and assign them to theGridDropDownColumns in the code behind?   

It could be more elegant and more efficient.

Please help me with this problem.

Thanks






Antonio Stoilkov
Telerik team
 answered on 26 Mar 2012
0 answers
180 views
Hello To All

I m trying to use rad org chart i m able to bind this from sqldatasource but the problem is that designing of this rad org chart is expanding (designing has been spoiled) means a long Horizontal line is coming, how can i over come from this problem.
Jack
Top achievements
Rank 1
 asked on 26 Mar 2012
3 answers
376 views
Hello, i am trying to use the allowcustomtext feature on the radcombo box, but whether i set the property in the code behind or the code front it fails to work.  All other properties appear to work OK. When I tried setting the property in the code behind under "selected index change" obviously same results.  Basically when i attempt to select a word(s) it selects everything and in order to modify the suggested value you have to use the "end" key then scroll left, end users are complaining.. please help.
<telerik:RadComboBox ID="cbActivity" runat="server" Skin="Windows7"
                   EnableLoadOnDemand="true" MarkFirstMatch="true" 
                   EnableVirtualScrolling="True" DataSourceID="SqlDataSource1" 
                   DataTextField="Activity" DataValueField="Activity" 
                   EmptyMessage="Enter New Activity or Select Pre-Existing" 
                   style="margin-bottom: 0px" Width="500px" AllowCustomText="true"
                   HighlightTemplatedItems="true" ShowMoreResultsBox="true">
               </telerik:RadComboBox>
attempt using code behind
protected void cbActivity_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        cbActivity.AllowCustomText = true;
    }
Kris
Top achievements
Rank 1
 answered on 26 Mar 2012
2 answers
129 views

 

 

 

 

 

Hi, I have a radgrid bound to an iList of objects. My list has objects of type "Voucher"

The user can select multiple rows in the grid.

I can enum through the selected rows using;

 

 

 

 


for each x in grd.SelectedItems

next

How can i get a reference to the underlying "Voucher" object the row is bound to?

thx!

 

 

 

 

 

 

 

 

Kim
Top achievements
Rank 1
 answered on 26 Mar 2012
2 answers
142 views
Hi Team,

         I'm trying open the pdf file from radwindow. I follow this thread Rad Window to Open Pdf . It work on Firefox not at IE8.
Someone can give me suggestion?

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function rbLegend_OnClientClicked(sender, args) {
                var rwLegend = $find("<%= rwLegend.ClientID %>");
                rwLegend.show();
                sender.set_autoPostBack(false);
            }          
        </script>
    </telerik:RadScriptBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rbLegend">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rwLegend" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
            <Windows>
                <telerik:RadWindow ID="rwLegend" runat="server" VisibleOnPageLoad="false" ShowContentDuringLoad="true">
                    <ContentTemplate>
                        <iframe id="iframe3" runat="server" width="99%" height="99%" src="2.pdf">
                        </iframe>
                    </ContentTemplate>
                </telerik:RadWindow>
            </Windows>
        </telerik:RadWindowManager>
        <telerik:RadButton ID="rbLegend" runat="server" Text="RadButton"
            OnClientClicked="rbLegend_OnClientClicked">
        </telerik:RadButton>
    </div>

Regards,
Alex
ALEX
Top achievements
Rank 1
 answered on 25 Mar 2012
3 answers
155 views
Hello, I have a Radgrid with a DetailTable inside. This Grid has orders with order items in the detail table.
I have a OnDataBound event on this Grid. This event checks for the value in a column and then sets the row backcolor on it.
It works fine until I try to expand into the detailtable since then it tries to execute the OnDatabound event and the field I am checking does not exists in the detail table.
Below is the OnDataBound event:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                TableCell myCell = dataItem["ready"];
                if ((myCell.Text == "True"))
                {
                    dataItem.BackColor = System.Drawing.Color.SteelBlue;
                }
            }
        }

The code fails when trying to expand into the detail table. It fails on line:
TableCell myCell = dataItem["ready"]; 
since the "ready" column does not exist in the detail table.

 Can someone let me know how I can fix this?
Thanks.
Shinu
Top achievements
Rank 2
 answered on 24 Mar 2012
3 answers
221 views
I am attempting to add a CustomValidator to a control in an EditItemTemplate, but cannot figure out how to get the values of the two objects involved in the OnServerValidate event. Have googled for information half a day with no success.

Based on a value entered in a TextBox with validation, I need to determine if a value exists in a RadDatePicker inside all within an EditItemTemplate. (edit mode)

Thanks,
SteveO...

 

<EditItemTemplate>

 

 

<asp:TextBox ID="nextact" runat="server" onclick="javascript:HighlightRow(this);" Text='<%# Bind("NextAct")%>' Width="20px" Style="text-transform:uppercase" ></asp:TextBox>

 

 

<asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="Next Act Date required" OnServerValidate="NextActDate_Validate" Display="Dynamic" > </asp:CustomValidator>

 

 

</EditItemTemplate>

 


Shinu
Top achievements
Rank 2
 answered on 24 Mar 2012
7 answers
185 views
Hi ALL,

Please help me on Creating RadDockZone object client side. Here i am posting my sever side code, the same code i need it in client side:
        RadDockZone rdzOuterZone = new RadDockZone();
        rdzOuterZone.ID = "rdzOuterZone";
        rdzOuterZone.EnableTheming = false;
        rdzOuterZone.Orientation = Orientation.Vertical;       
Its very urgent.... Help out me on this.

Thanks,
Abhishek K
Abhishek
Top achievements
Rank 2
 answered on 24 Mar 2012
5 answers
514 views
HI,
In the grid with inline editing the template is already defined with labels and text-boxes..But when the users clicks on the edit button on command item template i want the show the template with drop-downs i.e different template from current one.How can i do this?
Attached file is the screenschot taken in inline edit mode.
 i want to have dropdowns instead of text-boxes  , labels are same .on click of command in command item template.
Shinu
Top achievements
Rank 2
 answered on 24 Mar 2012
0 answers
108 views
Hello everyone!

I am developing a software for Textile Industry. I have a scenario in which there are 3 grids i am using. 1 for Warp Count, 1 for Weft Count and 1 for Composition. Maximum counts allowed are 4 in both warp and weft counts, In composition grid i am pulling composition from a setup table. What I need is to show 4 blank rows in warp and weft count grids as default so that the user can select desired yarn from the ComboBox. Warp and Weft Counts Grids contains 4 columns YarnSupplier, YarnQuality, YarnName and Ratio%. 

My question is how to show 4 rows when the webform opens. And what if i want to add a blank row after Ratio% entered in the column.

I have searched a lot but couldn't find any solution. Please help me to save my time in searching.

Please reply

Thanks and regards,
Shah
Top achievements
Rank 1
 asked on 24 Mar 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?