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

Hi

I am going round in circles trying to beat this problem which I fairly sure is a result trying bind the value of the combos box item to a column which may contain null value. The error occurs as soon as the the grid's 'Edit' button is clicked with some database items/

The relevant grid declaration is like this

<telerik:GridTemplateColumn DataField="Marshals" HeaderText="Marshal"
            SortExpression="Marshals" UniqueName="Marshals" Visible="False">
              
            <EditItemTemplate>         
                   <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                       AppendDataBoundItems="True" SelectedValue='<%# bind("Marshals") %>'
                       Width="225px">
                   </telerik:RadComboBox>
  
            </EditItemTemplate>
 <ItemTemplate>
                <asp:Label ID="MarshalsLabel" runat="server" Text='<%# Eval("Marshals") %>'></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>

And the code behind builds a dataset and binds to the combo
Protected Sub RadGrid1_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
 
        If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then
            Dim editform As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
            Dim combo As RadComboBox = DirectCast(editform.FindControl("RadComboBox1"), RadComboBox)
            Bind(combo)
            Dim combo2 As RadComboBox = DirectCast(editform.FindControl("RadComboBox2"), RadComboBox)
            Bind(combo2)
        End If
    End Sub
 
    Private Sub Bind(combo As RadComboBox)
        Dim strMemberID As String = ""
        Dim sb As New StringBuilder
 
 
        Dim Ds As New DataSet
        Dim UserTable As New DataTable("UserTable")
        UserTable.Columns.Add("Text", GetType(String))
        UserTable.Columns.Add("Value", GetType(String))
        UserTable.Rows.Add("Pick one", "0")
 
        Dim rdr As SqlDataReader = ConstClass.getCurrentMembers()
        If rdr.HasRows Then
            While rdr.Read()
                ' build a row of the combo
                ' Text
                If Not IsDBNull(rdr("FirstName")) Then
                    sb.Append(rdr("FirstName"))
                Else
                    sb.Append("")
                End If
                sb.Append(" ")
                If Not IsDBNull(rdr("LastName")) Then
                    sb.Append(rdr("LastName"))
                Else
                    sb.Append("")
                End If
                sb.Append(" & ")
                If Not IsDBNull(rdr("PartnerFirstName")) Then
                    sb.Append(rdr("PartnerFirstName"))
                Else
                    sb.Append("")
                End If
                sb.Append(" ")
                If Not IsDBNull(rdr("PartnerLastName")) Then
                    sb.Append(rdr("PartnerLastName"))
                Else
                    sb.Append("")
                End If
 
                If Not IsDBNull("MemberID") Then
                    strMemberID = rdr("MemberID")
                Else
                    strMemberID = "0"
                End If
 
                UserTable.Rows.Add(sb.ToString, strMemberID)
                sb.Clear()
            End While
            UserTable.AcceptChanges()
            Ds.Tables.Add(UserTable)
            Ds.AcceptChanges()
            rdr.Close()
 
 
            LiteralTest.Text = sb.ToString
        Else
            UserTable.Rows.Add(sb.ToString, strMemberID)
            UserTable.AcceptChanges()
            Ds.Tables.Add(UserTable)
            Ds.AcceptChanges()
            rdr.Close()
        End If
 
        combo.DataTextField = "Text"
        combo.DataValueField = "Value"
        combo.DataSource = Ds
 
    End Sub

This all works just fine until when you try to edit an item that has a Null value for 'Marshals' (which is an integer) in the record.
How do I escape?  I have tried several of the solutions in this forum that seem as if they might be my case but to no avail so far.

BTW I am using Q2 2010 on this website.

Thanks

Clive

Dimitar Terziev
Telerik team
 answered on 25 Apr 2012
1 answer
94 views
How to remove an item from a listbox client side asynchronously? I'm using RadAjaxManager, but I have to click the button 2 times to remove the item. 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="True">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RemoveFeed">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ListBoxFeeds" LoadingPanelID="ajaxLoading" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManage>

<telerik:RadListBox AppendDataBoundItems="true" runat="server" ID="ListBoxFeeds"
                CssClass="boxComments" AutoPostBack="True" RegisterWithScriptManager="True" AllowReorder="False"
                AllowTransfer="False" EnableDragAndDrop="False"
                AllowAutomaticUpdates="True">
       <ItemTemplate>
                            <asp:Button ID="RemoveFeed" OnClick="removeFeed_Click" CssClass="removeItem" runat="server"
                                Text="Test"/>
       </ItemTemplate>
            </telerik:RadListBox>
Bozhidar
Telerik team
 answered on 25 Apr 2012
1 answer
251 views
Hi, 
I am using Temlplate column in Radgrid with Link Button as TemplateItem,
I am unable to select the row on item click at server side
 how to access the column values of that particular row on click of link button at server side.

code is as follows
<MasterTableView AutoGenerateColumns="false" AllowSorting="true" CssClass="radgrid">
                    <Columns>
                        <telerik:GridTemplateColumn AllowFiltering="false">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkSelect" runat="server" OnClick="lnkSelect_Click">Select</asp:LinkButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn HeaderText="Code" UniqueName="Code" DataField="rolnam" AllowFiltering="true"
                            AllowSorting="true">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Description" UniqueName="Description" DataField="roldsc"
                            AllowFiltering="true" AllowSorting="true">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>

Please let me know.
Jayesh Goyani
Top achievements
Rank 2
 answered on 25 Apr 2012
1 answer
70 views
Hi Telerik Team,

I want to slide/Hide "RadSlidingPane" automatically on the click of button on a page.

I have tried with DockOnOpen,EnableDock but it doesn't open automatically when i click on the button, 

Can you please help me how to fix this one?

Thanks,
Simon.
Dobromir
Telerik team
 answered on 25 Apr 2012
3 answers
153 views
Hi there,

I've read your article http://www.telerik.com/help/aspnet-ajax/radimageeditor-localization.html which shows that there are 3 default files for different languages. However, i couldn't find the default files, therefore i dont know what is the resource keys for the RadIamgeEditor.

Where can i retrieve the resx files?

Regards,
Dexter
Rumen
Telerik team
 answered on 25 Apr 2012
1 answer
218 views
Filefilter is not working at the first time.

When i add a invalid file. it display the file name in red.
  
then i remove and try to add another file.

Now the FileFilter works fine
Peter Filipov
Telerik team
 answered on 25 Apr 2012
5 answers
311 views
What I have is a radgrid with one column we are binding a persons email to it so that someone can click on the column and open outlook and then email someone.  But what happens is that it actually forwards the page and errors out, it still opens outlook but errors out the page.  Tired with a hyperlink and then tried seperately with a a href, both act the same way in forwarding the page to the persons email which errors it out.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnUpdateCommand="RadGrid1_UpdateCommand">
            <MasterTableView>
                <Columns>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                            <asp:HyperLink NavigateUrl='<%# Bind("Name", "mailto:{0}") %>' Text='<%# Bind("Name") %>'
                                runat="server" ID="hlEmail"></asp:HyperLink>
                                <br />
                                <a href='<%# "mailto:" + Eval("Name") %>'><%# Eval("Name") %></a>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>


Antonio Stoilkov
Telerik team
 answered on 25 Apr 2012
8 answers
121 views
Hey Everybody!


I am redoing a clients site from classic asp to asp.net, and all is well up until it came down to a grid.


In short,

The grids columns are dynamic, as the customers site sells clothing, and sizes are dependent on the clothing size.

The grids should contain the contents of:

http://www.logodogzthreadz.com/productdisplay.asp?productID=201 

If you look down below 'Step 1', you'll see the colors name, a preview, and the sizes in columns with textboxes.


So, my question for you is this...


1. How could I add text boxes to a column programatically (in VB)
2. How could I add a color preview? It uses Hex codes, maybe add a label, make it blank and set the backcolor?

A code snippet would be fantastic.

Elliott
Top achievements
Rank 2
 answered on 25 Apr 2012
4 answers
71 views
Hi
 This is another error that I am getting:
Microsoft Jscript error. rows.0.cells is null or not and objehct

I get the above mentioned error when I transfere the database connection from the ASP.NET connetions in the code behind. I used the example http://demos.telerik.com/aspnet-ajax/scheduler/examples/resourceavailability/defaultcs.aspx.

The demo works fine as it is but  when I do the changes to bind the RadScheduler from code behind, I get errors.

This is my code behind, please assist:

 protected void Page_Load(object sender, EventArgs e)
        {
           // XmlDocument xDoc = new XmlDocument();
          //  xDoc = DataTableToXmlDocument(getAppointment);
            //r order = xDoc.ChildNodes[2];
          // XmlDataSource1.Data = DataTableToXmlDocument(getAppointment).InnerXml;
           // xDoc = DataTableToXmlDocument(getAppointment).InnerXml;
            getmyAppointments();
            getmyRooms();
           
         // XmlDataSource1.DataBind();
        }
     
        public void getmyRooms()
        {
            SqlConnection myConnection = new SqlConnection();
            myConnection.ConnectionString = WebConfigurationManager.ConnectionStrings["Localstring"].ConnectionString;  
            SqlCommand myCommand = new SqlCommand();
            myCommand.CommandText = "SELECT [RoomID], [Name] FROM [Grouping_Rooms]";  
            myCommand.Connection = myConnection;  
            SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);  
            DataSet productsDataSet = new DataSet();  
            myAdapter.Fill(productsDataSet);
           
            ResourceType RT = new ResourceType();
            RT.DataSource = productsDataSet.Tables[0];
            RT.KeyField = productsDataSet.Tables[0].Columns[0].ToString();
            RT.ForeignKeyField = productsDataSet.Tables[0].Columns[0].ToString();
            RT.TextField= productsDataSet.Tables[0].Columns[1].ToString();
            RadScheduler1.ResourceTypes.Add(RT);
           
            
        }

        public void getmyAppointments()
        {
            SqlConnection myConnection = new SqlConnection();
            myConnection.ConnectionString = WebConfigurationManager.ConnectionStrings["Localstring"].ConnectionString;  
            SqlCommand Command = new SqlCommand();
            Command.CommandText = "SELECT [ID], [Description], [Start], [End], [RoomID], [RecurrenceRule], [RecurrenceParentID] FROM [Grouping_Events]";  
            Command.Connection = myConnection;  
            SqlDataAdapter Adapter = new SqlDataAdapter(Command);  
            DataSet AppDataSet = new DataSet();
            Adapter.Fill(AppDataSet);
           // RadScheduler1.
            RadScheduler1.DataKeyField = AppDataSet.Tables[0].Columns[0].ToString();
            RadScheduler1.DataSubjectField = AppDataSet.Tables[0].Columns[1].ToString();
            RadScheduler1.DataStartField = AppDataSet.Tables[0].Columns[2].ToString();
            RadScheduler1.DataEndField = AppDataSet.Tables[0].Columns[3].ToString();
            RadScheduler1.DataSource = AppDataSet.Tables[0];
          
            RadScheduler1.DataBind();
          
        }
Peter
Telerik team
 answered on 25 Apr 2012
12 answers
429 views
So I figured out how to have multiple radgrids and allow them to export to one page, which is great!
But I have an issue, I need the grids to fit on the screen of the web browser and they aren't.
I have two radgrids, one that has two columns and another that has about 10+ columns underneath. They are both within a radgrid, when I try to reduce the width nothing works, I have a scroll bar on the bottom the of browser which I don't want. The width of both radgrids are at 100% but the grid extends the screen to double instead of 100% being the screen itself, therefore not working properly.
Is there any way to have the scroll bar on one of the radgrids and not both? I have tried the Client Settings with Scrolling and it's working but I have 4 columns missing. I have also provided some code:

Can I get some help?
Anil Nautiyal
Top achievements
Rank 1
 answered on 25 Apr 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?