Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
123 views
Hello,

What I'm trying to do is essentially create a "Read-Only" combobox so the user can't make it dropdown or otherwise select anything.  I've prevented the dropdown, but they can still change it the value if they select it and then use the arrow keys to scroll down.  Is there a way to prevent this?
Gama
Top achievements
Rank 1
 answered on 21 Jul 2010
3 answers
219 views
                    <telerik:RadGrid ID="rgGrid" runat="server" AutoGenerateColumns="False" AllowAutomaticInserts="True"
                        AllowAutomaticDeletes="True" AllowAutomaticUpdates="True" DataSourceID="ldsProfiles"
                        GridLines="None" Skin="Office2007" BorderWidth="0px" OnItemCommand="rgGrid_ItemCommand"
                        OnItemUpdated="rgGrid_ItemUpdated" OnItemInserted="rgGrid_ItemInserted" OnItemCreated="rgGrid_ItemCreated"  >
                        <MasterTableView DataKeyNames="ProposalAttachmentID" DataSourceID="ldsProfiles"
                            EditMode="EditForms" CommandItemDisplay="Top" >
                            <CommandItemStyle CssClass="gridHeader" />
                            <CommandItemTemplate>
                                <div class="gridHeader">
                                    Files
                                </div>
                                  
                                <div class="sectionHeaderButton" style="margin-left: 10px;">
                                    <asp:LinkButton ID="rgProAddButton" runat="server" Text="(add)" CommandName="InitInsert" Visible='<%# 
  
!rgGrid.MasterTableView.IsItemInserted   %>' />
                                </div>
                                   
                            </CommandItemTemplate>
                            <Columns>
                                <telerik:GridBoundColumn DataField="UploadDate" DataType="System.DateTime" HeaderText="Date"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="UploadDate"
                                    UniqueName="UploadDate" DataFormatString="{0:MM/dd/yyyy}" ItemStyle-Width="13%">
<ItemStyle Width="13%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="User.FullName" DataType="System.String" HeaderText="Author"
                                    ForceExtractValue="InEditMode" ReadOnly="true" SortExpression="User.FirstName"
                                    UniqueName="User.FullName" ItemStyle-Width="15%">
<ItemStyle Width="15%"></ItemStyle>
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn DataField="FileName" HeaderText="File" SortExpression="FileName"
                                    UniqueName="FileName" EditFormHeaderTextFormat="">
                                    <ItemTemplate>
                                                
                                        <asp:HyperLink ID="lbPorfiles" runat="server"  NavigateUrl='<%# UploadPath+"/"+Eval("ProposalFK")+"/"+ Eval("User.Login") 
  
+"/"+ Eval("FileName")%>' Target="_blank"  Text='<%# Bind("FileName")%>'></asp:HyperLink>
                                          
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <div style="left">
                                            <telerik:RadUpload ID="rdProfile" runat="server" InitialFileInputsCount="1"  
                                                MaxFileInputsCount="5" Localization-Add="Add More Files" EnableFileInputSkinning="true"
                                                ControlObjectsVisibility="AddButton" MaxFileSize="1000000" OnClientFileSelected="ValidateExtension"   
                                                AllowedFileExtensions=".doc,.pdf,.ppt,.xls" OnClientAdded="addTitle" Skin="Office2007" 
                                                Width="95%" InputSize="35">  
                                                <Localization Add="Add More Files" />
                                            </telerik:RadUpload>
                                            <span id="fileExtentionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Invalid file 
  
extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls</span
                                            <span id="nullDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please enter 
  
Description</span
                                            <span id="overDescriptionError" class="error" style="display:none; color:#cc0000; font-weight:bold">* Please limit 
  
Description to 150 characters or less</span>                                                                                         
                                            <asp:CustomValidator Text="" runat="server" ID="FileUploadValidator" OnServerValidate="FileUpload_ServerValidate" 
  
ClientValidationFunction="ValidateFileUpload" />
                                            <%--        *Invalid file extensions. Only the following file formats can be uploaded: .doc,.pdf,.ppt,.xls
                                            </asp:CustomValidator> --%>                                                                                   
                                            <script type="text/javascript">
                                                function ValidateFileUpload(source, arguments)
                                                {
                                                    var radGrid = $find('<%= rgGrid.ClientID %>');
  
                                                    var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
  
                                                    var fileInputs = radUpload.getFileInputs()
                                                    var isValid = true;
  
  
                                                    //var descValue = $get('<%= rgGrid.ClientID %>' + 'Title' + i).value
                                                    var descValue = $get(radUpload.getID() + 'Title' + i).value                                                    
                                                      
                                                    //alert(descValue)
                                                    for (var i = 0; i < fileInputs.length; i++)
                                                    {
  
                                                    }
  
                                                    arguments.IsValid = isValid;
                                                }
                                                  
                                                var i = 0
                                                  
                                                function addTitle(sender, args)
                                                {
                                                    var inputRow = args.get_row();
                                                    var fileInputSpan = inputRow.getElementsByTagName("span")[0];
  
                                                    var tAddField = sender.getID("Title");
  
                                                    $(".ruInputs li[class='']:last span").after($("<textarea rows=3 cols='50'/>").attr("id", tAddField).attr("name", 
  
tAddField)).after($("<label class='fileInputLabel'>Description : </label>").attr("for", tAddField)).before($("<label class='fileInputLabel'>  File : 
  
</label>").attr("for", fileInputSpan));                                         
                                                }
  
                                            </script>
                                                                                           
                                        </div>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                        </MasterTableView>
                    </telerik:RadGrid>
I have a RadUpload control in EditTemplate inside a RadGrid.
I add the client code to add addtional field with TextArea type allowing user to enter comment for the uploading file.
And that additional comment field is a required field, also only 500 characters max limited.
I want a TextArea type because I want to user to see all the text they enter and input type=text just won't do the justification.
I seem to have a problem to get the addional field's value at client side code. 

I use  
   var radGrid = $find('<%= rgGrid.ClientID %>');

to get the grid control
and  
   var radUpload = $telerik.findControl(radGrid.get_element(), "rdProfile");
to get the upload control

When I try to retrive the value of the additional field by code similar to
   var descValue = $get(radUpload.getID() + 'Title' + i).value 
I am getting javascript error saying "object needed"

Anyone can help?
I attached my code

kevin yang
Top achievements
Rank 1
 answered on 21 Jul 2010
2 answers
292 views
Hi,

I have two DataTable objects that both contain the same data (first contains data before a certain change, second has the data after that change).

Assuming that both tables have the same number of records, is there any way to show differences between the tables in a nice, user-friendly way using Telerik RadGrid (or maybe any other Telerik control)?

Thanks,
Michael
Michael
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
220 views
I have a simple FormTemplate that I am trying to grab the values from to perform an insert/update. I am trying to grab a Listbox to create a comma delimited list of the values that it contains. When I try to access it I get a null pointer. However, I can successfully access other controls in the same FormTemplate. Anyone have any ideas?

The control I am trying to access is the lstSelectedUsers control.

ASPX page:

<EditFormSettings EditFormType="Template" InsertCaption="Create new User Group" CaptionDataField="group_name" CaptionFormatString="Editing Group: <b>{0}</b>" PopUpSettings-Width="610px">
                            <FormTemplate>
                                <div style="padding-left:5px">
                                    <table border="0" cellpadding="2" cellspacing="0">
                                        <tr>
                                            <td>
                                                Name:
                                            </td>
                                            <td>
                                                <asp:TextBox runat="server" ID="GroupName" Text="<%# Bind('group_name') %>"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="vertical-align: top">
                                                Description:
                                            </td>
                                            <td>
                                                <asp:TextBox runat="server" ID="Description" Text="<%# Bind('description') %>" Wrap="true"
                                                    Width="300px" Height="35px" TextMode="MultiLine"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Public:
                                            </td>
                                            <td>
                                                <asp:CheckBox ID="isPublic" runat="server" Checked='<%# (DataBinder.Eval(Container.DataItem,"is_public").ToString()!="0"?true:false) %>'
                                                    TabIndex="1" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Users:
                                            </td>
                                            <td>
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr class="LightBackground">
                                                        <td style="border: 1px solid gray;border-bottom:none;border-right:none;padding:3px"><b>Available</b></td>
                                                        <td style="border: 1px solid gray;border-bottom:none;border-left:none;padding:3px"><b>Selected</b></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <telerik:RadListBox runat="server" ID="lstAvailableUsers" AutoPostBackOnTransfer="false" Sort="Ascending" ButtonSettings-VerticalAlign="Middle" SelectionMode="Multiple" AllowTransfer="true" Width="240px" Height="150px" TransferMode="Move" AllowTransferOnDoubleClick="true" TransferToID="lstSelectedUsers" DataSourceID="dsAvailableUsers" DataKeyField="user_id" DataTextField="display_name"></telerik:RadListBox>
                                                        </td>
                                                        <td>
                                                            <telerik:RadListBox runat="server" ID="lstSelectedUsers" AutoPostBackOnTransfer="false" Sort="Ascending" Width="240px" Height="150px" SelectionMode="Multiple" AllowTransferOnDoubleClick="true" TransferToID="lstAvailableUsers"  DataSourceID="dsSelectedUsers" DataKeyField="user_id" DataTextField="display_name"></telerik:RadListBox>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                            </td>
                                            <td>
                                                <br />
                                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                                </asp:Button>&nbsp;
                                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                    CommandName="Cancel"></asp:Button>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </FormTemplate>
                        </EditFormSettings>


************************ CodeBehind ************************************************************

protected void grdUserGroups_UpdateCommand(object source, GridCommandEventArgs e)
    {
        //Get the GridEditFormInsertItem of the RadGrid     
        GridEditFormItem item = (GridEditFormItem)e.Item;

        try
        {
            SqlConnection conn = Database.getConnection();

            String groupId = (item.KeyValues.Substring(11, item.KeyValues.Length - 13));

            string sql = "Update USER_GROUPS set group_name=@groupName, description=@description, is_public=@isPublic where group_id=@groupId";
            SqlCommand cmd = new SqlCommand(sql, conn);
            cmd.Parameters.AddWithValue("@groupName", (item.FindControl("groupName") as TextBox).Text);
            cmd.Parameters.AddWithValue("@description", (item.FindControl("description") as TextBox).Text);
            cmd.Parameters.AddWithValue("@isPublic", (item.FindControl("isPublic") as CheckBox).Checked ? "1" : "0");
            cmd.Parameters.AddWithValue("@groupId", groupId);
            cmd.ExecuteNonQuery();

********* THIS IS THE LINE THAT FAILS - The other FindControls up above work fine **************************************
            RadListBox lstSel = item.FindControl("lstSelectedUsers") as RadListBox;
            StringBuilder userIds = new StringBuilder();
            foreach (RadListBoxItem lstItem in lstSel.Items)
            {
                if (userIds.Length > 0)
                    userIds.Append(",");

                userIds.Append(lstItem.Value);
            }

            cmd = new SqlCommand("INSERT INTO USER_GROUP_MEMBERS (user_id, group_id) SELECT user_id, @groupId FROM users WHERE user_id in (" + userIds + ")", conn);
            cmd.Parameters.AddWithValue("@groupId", groupId);
            cmd.ExecuteNonQuery();

            conn.Close();
        }
        catch (Exception ex)
        { HandleGridStatus(ex, "inserted"); }
    }
Robert Bross
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
923 views
Hi,

I'm adding a RadGrid to a page and am having issues getting my table data to display.

The grid is generally working, but every cell displays as 'system.data.datarowview' - looks like it's calling ToString() on the wrong object?

I am populating the grid entirely in code, but am declaring it statically in my ASPX.
I create the columns in the Page_Load method (when !IsPostback) - there is a variety of GridBoundColumns and GridHyperlinkColumns. The columns are instantiated, added to the grid.MasterTableView.Columns collection, and *then* have additional properties set.

When the time comes to populate the grid (during a partial postback event), I have a helper class that produces a DataTable object with columns with names that match the GridColumns in the grid.

I finally call Rebind() and set the DataSource of the grid to my DataTable in the NeedDataSource event.

When stepping through some of the events (I create a custom paging control), I can clearly see that my data is present in the DataSource, but it's not making it through to the grid.

If I set the grid to AutoGenerateColumns=true in my ASPX, I get duplicate columns, but the auto generated ones are displaying my cell data correctly.

I suspect I'm missing some step in wiring the DataTable columns to the GridColumns. Any advice?

Thanks,
Stefan
Stefan
Top achievements
Rank 1
 answered on 21 Jul 2010
2 answers
84 views
hi,

i used the textbox inside the panelbar i used the following codes the find the controle but the value i'm getting from the textbox is null

foreach (RadPanelItem PanelItem in RadPanelBar1.GetAllItems())
{
RadTextBox txtAge = RadPanelBar1.FindControl("txtAge") as RadTextBox;
RadTextBox txtWeight = RadPanelBar1.FindControl("txtWeight") as RadTextBox;
health.Age = Convert.ToInt32(txtAge.Text);
health.weight = Convert.ToInt32(txtWeight.Text);
}

the value of txtAge and txtWeight is always null even if i gave different value in runtime
how to get the value of the textbox entred in run time.

Regards
Priya

 
Matthew
Top achievements
Rank 1
 answered on 21 Jul 2010
8 answers
181 views
I have 'program' radlistbox that I am populating dynamically. I also add a RadListBoxItem '[ ALL ]' to this listbox which is used to select all the items.

I populate the other radlistbox depending on the selection in the 'program' radlistbox.

The issue is: I selected '[ ALL ]' from 'program' listbox. This selected all the items in the listbox and populated the other listbox accordingly. But now when i select just one item from the 'program' listbox nothing happens, the 'SelectedIndexChanged' does not fire.
Please help???

-- Code to insert the RadListBoxItem

Me

 

.rlbProgram.Items.Insert(0, New RadListBoxItem("[ ALL ]", 0))

-- Code that I use to loop through the listbox to select them all when '[ ALL ]' is clicked.

 

Select

 

Case Me.rlbProgram.SelectedIndex

 

 

Case 0

 

 

For i As Integer = 1 To Me.rlbProgram.Items.Count - 1

 

 

Me.rlbProgram.Items(i).Selected = True

 

 

 

 

sPrograms.AppendFormat(

"<Program id='{0}'/>{1}", Me.rlbProgram.Items(i).Value, vbCrLf)

 

 

Next

 

 

 

 

 

End Select

 

Ajay Gandhi
Top achievements
Rank 1
 answered on 21 Jul 2010
3 answers
118 views
I just upgraded to the new Q2 2010 tools and the RadGrid's AutoGenerateHierarchy is gone!  Now all of my DataRelations that I set up in the datasets do not have any impact on the RadGrid and I only see the top level.  Has the functionality been removed or just moved to a different method?  How can I get this to work in the Q2 tools?
JD Plagianis
Top achievements
Rank 1
 answered on 21 Jul 2010
1 answer
103 views
I've noticed that with you set EnableAutomaticLoadOnDemand="true" and Filter="StartsWith", when you select one of the items and then start scrolling it starts filtering out all the other items and the message box shows incorrect counts and allows you to continue scrolling until you reach the count it mentions.

It's kind of hard to explain, but you can see it being done on your demo page:

http://demos.telerik.com/aspnet-ajax/combobox/examples/loadondemand/automaticloadondemand/defaultcs.aspx

If you open the drop-down, select one of the options and then open up the drop-down you'll see the issue I'm referring to. It starts clearing out the other items, but still allows you to scroll.

I have to assume this is a bug with the AutomaticLoadOnDemand feature.
Simon
Telerik team
 answered on 21 Jul 2010
2 answers
195 views
 
I Â´m not using DatasourceID, and I don´t know why happend this.  
This is a common error, some times happend. And I don´t know which is the problem.  
Thank´s. 



Server Error in '/' Application.


Both DataSource and DataSourceID are defined on 'RadMenu1'.  Remove one definition.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'.  Remove one definition.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace: 

 
[InvalidOperationException: Both DataSource and DataSourceID are defined on 'RadMenu1'.  Remove one definition.]
   System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView() +10834996
   System.Web.UI.WebControls.DataBoundControl.OnLoad(EventArgs e) +28
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Control.LoadRecursive() +191
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

 


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

 

 

 

Fabian Raul Jofre
Top achievements
Rank 2
 answered on 21 Jul 2010
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?