Getting no items in hashTable when editing

2 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    4 posts
    Member since:
    Jun 2010

    Posted 28 Jun 2010 Link to this post

    Have 2 questions, but the error first.  When I select the edit button after changed the rule name, no values are put into my newValues hashtable.  So my edit never takes place.  Other question is I have 2 controls to help create 1 item for a column during edit. How would I combine the control values during the edit.  The two controls are a datepicker and a timeselector control.

    Code Behind
       protected void ruleLV_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
        {
            ruleLV.DataSource = dt;
        }

        protected void ruleLV_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
            if (e.CommandName == RadListView.CancelCommandName)
            {
                ruleLV.InsertItemPosition = RadListViewInsertItemPosition.None;
               // ruleLV.FindControl("Button1").Visible = true;
            }
            else if (e.CommandName == RadListView.UpdateCommandName)
            {
                RadListViewEditableItem item = (RadListViewEditableItem)e.ListViewItem;
                Hashtable newValues = new Hashtable();
                item.ExtractValues(newValues);

                DataTable newDT = dt;
                DataRow[] changedRows = newDT.Select("RuleID = " + e.ListViewItem.OwnerListView.DataKeyValues[e.ListViewItem.OwnerListView.EditIndexes[0]]["RuleID"].ToString());


                if (changedRows.Length != 1)
                {
                    e.Canceled = true;
                    return;
                }
                changedRows[0].BeginEdit();
                try
                {
                    foreach (DictionaryEntry entry in newValues)
                    {
                        changedRows[0][(string)entry.Key] = entry.Value;
                    }
                    changedRows[0].CancelEdit();
                    this.ViewState["_lvds"] = newDT;
                }
                catch (Exception ex)
                {
                    changedRows[0].CancelEdit();
                    e.Canceled = true;
                }



            }
        }

    MarkUp

     <telerik:RadListView ID="ruleLV" runat="server" AllowPaging="True"
                    DataKeyNames="RuleID" ItemPlaceholderID="RulePlaceHolder"
                    onitemcommand="ruleLV_ItemCommand" onneeddatasource="ruleLV_NeedDataSource"
                    PageSize="5" Skin="Windows7">
                    <LayoutTemplate>
                        <table ID="Table1" runat="server">
                            <tr>
                                <th ID="SummaryIdHdr" runat="server" width="150px">
                                    Rule ID</th>
                                <th ID="BegTimeStampHdr" runat="server" width="200px">
                                    Start Date/Time</th>
                                <th ID="EndTimeStampHdr" runat="server" width="200px">
                                    End Date/Time</th>
                            </tr>
                            <tr ID="RulePlaceHolder" runat="server">
                            </tr>
                        </table>
                        <fieldset style="text-align: center; background-color: white;">
                        </fieldset>
                    </LayoutTemplate>
                    <EditItemTemplate>
                        <tr ID="rules" runat="server" bgcolor="white">
                            <td>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SummaryID") %>'> </asp:TextBox>
                            </td>
                            <td>
                                <telerik:RadDatePicker ID="startDate" runat="server"
                                    Calendar-ShowRowHeaders="false" SelectedDate='<%# Bind("BegTimeStamp") %>'>
                                </telerik:RadDatePicker>
                            </td>
                            <td>
                                <MKB:TimeSelector ID="time1" runat="server" Date='<%# Bind("BegTimeStamp") %>'
                                    MinuteIncrement="1">
                                </MKB:TimeSelector>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("BegTimeStamp") %>'></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("EndTimeStamp") %>'></asp:TextBox>
                            </td>
                            <td>
                                <asp:Button ID="Button1" runat="server" CommandName="Update" Text="Update"
                                    Width="70px" />
                            </td>
                            <td>
                                <asp:Button ID="Button2" runat="server" CausesValidation="false"
                                    CommandName="Cancel" Text="Cancel" Width="70px" />
                            </td>
                        </tr>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <tr ID="rules0" runat="server" bgColor="White">
                            <td>
                                <%#Eval("SummaryID") %></td>
                            <td>
                                <%#Eval("BegTimeStamp") %></td>
                            <td>
                                <%#Eval("EndTimeStamp") %></td>
                            <td>
                                <asp:Button ID="Button1" runat="server" CommandName="Edit" Text="Edit" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </telerik:RadListView>
                <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="ruleLV"
                    PageSize="1" Width="550px">
                    <Fields>
                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                        <telerik:RadDataPagerButtonField FieldType="Numeric" />
                        <telerik:RadDataPagerButtonField FieldType="NextLast" />
                        <telerik:RadDataPagerPageSizeField />
                    </Fields>
                </telerik:RadDataPager>

  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 29 Jun 2010 Link to this post

    Hello Jeremy,

    The reason behind values not been extracted is that unfortunately ASP.NET does not support two-way databinding when the expressions are nested inside a table with runat=server attribute. Same behavior can be observed with any templated control in such configuration.
    Therefore you should consider either extract values manually, by directly accessing the inner controls, or convert the table to a non server control by removing the runat=server attributes from the appropriate elements.

    Regards,
    Rosen
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top