单击编辑时Telerik RadGrid消失

时间:2016-09-08 16:20:07

标签: c# asp.net telerik radgrid

我已经通过网上的几个线程来解决这个问题,似乎没有一个能帮我解决问题......

我有一个RadGrid包含在onneeddata事件中的数据绑定弹出窗口中。在这种情况下,会话变量中包含搜索功能。无论如何,它一切正常,窗口和网格出现并正确填充,但当我点击编辑...整个网格消失。如果我点击"搜索"再次按下按钮,网格重新出现,现在处于编辑模式。

任何建议都将深表感谢!

编辑以添加代码:

   <telerik:RadWindow ID="searchWindow" runat="server" Width="1400px" 
               >
                <ContentTemplate>
                 <h2>Search Results</h2>
          <telerik:RadGrid ID="searchGrid" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" CellSpacing="0" DataMember="ID" GridLines="None" 
            onitemcommand="searchGrid_ItemCommand" onneeddatasource="searchGrid_NeedDataSource" 
            OnUpdateCommand="searchGrid_UpdateCommand" PageSize="10" 
                onitemdatabound="searchGrid_ItemDataBound" BackColor="#FFFF99" EnableViewState="True"><mastertableview 
            datakeynames="status,charity,make,model,year,vin,date,id,salePrice,bid,note" 
            editmode="EditForms">

<commanditemsettings exporttopdftext="Export to PDF"></commanditemsettings>

<rowindicatorcolumn filtercontrolalttext="Filter RowIndicator column" visible="True">
<HeaderStyle Width="20px"></HeaderStyle>
</rowindicatorcolumn>

<expandcollapsecolumn filtercontrolalttext="Filter ExpandColumn column" visible="True">
<HeaderStyle Width="20px"></HeaderStyle>
</expandcollapsecolumn>

    <Columns>
    <telerik:GridButtonColumn AutoPostBackOnFilter="True" CommandName="History" 
            HeaderButtonType="PushButton" HeaderText="History" Text="History" 
            UniqueName="detailBtn">
                        </telerik:GridButtonColumn>
                          <telerik:GridBoundColumn DataField="name" DataType="System.String" 
            FilterControlAltText="Filter column2 column" HeaderText="Donor" 
            ItemStyle-Width="140px" ReadOnly="True" UniqueName="searchGridDonorCol" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="phone" DataType="System.String" 
            FilterControlAltText="Filter column2 column" HeaderText="Donor Phone" 
            ItemStyle-Width="140px" ReadOnly="True" UniqueName="searchGridDonorPhoneCol" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
     <telerik:GridBoundColumn DataField="charity" DataType="System.String" 
            FilterControlAltText="Filter column2 column" HeaderText="Consignor" 
            ItemStyle-Width="140px" ReadOnly="True" UniqueName="searchGridcolumn3" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="vin" DataType="System.String" 
            FilterControlAltText="Filter column6 column" HeaderText="VIN" 
            ItemStyle-Width="140px" UniqueName="searchGridcolumn7" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
             </telerik:GridBoundColumn>
      <telerik:GridBoundColumn DataField="year" DataType="System.Int32" 
            FilterControlAltText="Filter column2 column" HeaderText="Year" 
            ItemStyle-Width="140px" UniqueName="searchGridcolumn2" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="make" DataType="System.String" 
            FilterControlAltText="Filter column column" HeaderText="Make" 
            ItemStyle-Width="140px" UniqueName="searchGridcolumn" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="model" DataType="System.String" 
            FilterControlAltText="Filter column1 column" HeaderText="Model" 
            ItemStyle-Width="140px" UniqueName="searchGridcolumn1" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
            </telerik:GridBoundColumn>            
             <telerik:GridBoundColumn DataField="date" DataType="System.DateTime" 
            FilterControlAltText="Filter column1 column" HeaderText="Last Update" 
            ItemStyle-Width="140px" ReadOnly="True" UniqueName="searchGridcolumn5" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
         <telerik:GridBoundColumn DataField="bid" DataType="System.Decimal" 
            FilterControlAltText="Filter column1 column" HeaderText="Min. Bid" 
            ItemStyle-Width="140px" UniqueName="searchGridcolumn8" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="salePrice" DataType="System.String" 
            Display="False" FilterControlAltText="Filter column1 column" 
            HeaderText="Sale Price" ItemStyle-Width="140px" 
            UniqueName="searchGridPriceCol" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn> 
          <telerik:GridBoundColumn DataField="notes" DataType="System.String" 
            Display="True" FilterControlAltText="Filter column1 column" HeaderText="Notes" 
            ItemStyle-Width="140px" UniqueName="searchGridNotesColumn" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
   </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="stock" DataType="System.String" 
            Display="True" FilterControlAltText="Filter column1 column" HeaderText="Stock#" 
            ItemStyle-Width="140px" UniqueName="searchGridStockColumn" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn>  <telerik:GridBoundColumn DataField="reference" 
            DataType="System.String" Display="True" 
            FilterControlAltText="Filter column1 column" HeaderText="Cust. Ref" 
            ItemStyle-Width="140px" UniqueName="searchGridRefColumn" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Center">
<ItemStyle Width="140px"></ItemStyle>
        </telerik:GridBoundColumn> 
    <telerik:GridTemplateColumn HeaderText="Latest Status" ItemStyle-Width="240px">


                        <ItemTemplate>

                            <%#DataBinder.Eval(Container.DataItem, "Status")%>

                        </ItemTemplate>


                        <EditItemTemplate>

                            <telerik:RadComboBox ID="searchGridComboBox" runat="server" 
                                DataSourceID="LinqDataSource1" DataTextField="Status" DataValueField="ID" 
                                RenderMode="Lightweight">

                            </telerik:RadComboBox>                          

                        </EditItemTemplate>


<ItemStyle Width="240px"></ItemStyle>


                    </telerik:GridTemplateColumn>

                    <telerik:GridEditCommandColumn FooterText="EditCommand footer" 
            HeaderStyle-Width="100px" HeaderText="Edit" UniqueName="searchGridEditCommandColumn" 
            UpdateText="Update">

<HeaderStyle Width="100px"></HeaderStyle>

                    </telerik:GridEditCommandColumn>


    </Columns>

<editformsettings editcolumn-datatype="System.String">
<editcolumn filtercontrolalttext="Filter EditCommandColumn column"></editcolumn>
</editformsettings>
</mastertableview>

<filtermenu enableimagesprites="False"></filtermenu>
    </telerik:RadGrid>
                </ContentTemplate>
            </telerik:RadWindow>

And the databinding:

     if (Session["Search"] != null)
            {
                datablahblah db = new BlahBlahDataContext();
                string searchText = Session["Search"].ToString();
                var ud = db.Updates

                  .GroupBy(c => c.Vehicle, x => x, (x, gr) => new
                  {
                      key = x,
                      list = gr.ToList().OrderByDescending(z => z.TimeStamp).First()
                  })

                  .Select(x => x.list).ToList();
                var searchVehicles = (from u in ud
                                      join v in db.Vehicles on
                                          u.Vehicle equals v.ID
                                      where
                                          v.VIN_.Contains(searchText) || v.Stock_.Contains(searchText)
                                      join d in db.Donors on
                                      v.DonatedBy equals d.ID
                                      join c in db.Customers on
                                      v.Charity equals c.ID
                                      select new
                                      {
                                          status = u.Status,
                                          make = v.Make,
                                          model = v.Model,
                                          Year = v.Year,
                                          vin = v.VIN_,
                                          charity = c.Name,
                                          date = u.TimeStamp,
                                          id = u.Vehicle,
                                          salePrice = v.SalePrice,
                                          bid = v.MinimumBid,
                                          note = u.Note,
                                          stock = v.Stock_,
                                          reference = v.CustomerRef_,
                                          name = d.DonorLastName,
                                          phone = d.DonorPhone
                                      }).OrderBy(z => z.charity).ToList();

                searchGrid.DataSource = searchVehicles;

                searchWindow.VisibleOnPageLoad = true;

0 个答案:

没有答案