This is a migrated thread and some comments may be shown as answers.

When clicking on row to edit than grid show empty.

4 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MK
Top achievements
Rank 1
MK asked on 10 Sep 2012, 10:29 AM
My code :

<telerik:RadGrid ID="RadGridOrder" ShowStatusBar="true" runat="server" OnNeedDataSource="RadGridOrder_NeedDataSource"
                        OnItemDataBound="RadGridOrder_ItemDataBound" Width="100%" AutoGenerateColumns="False"
                        AllowMultiRowSelection="False" GridLines="None" AllowAutomaticUpdates="True"
                        OnItemUpdated="RadGridOrder_ItemUpdated" EnableViewState="true" OnEditCommand="RadGridOrder_ItemEdit"
                        OnDataBound="RadGridOrder_DataBound" OnItemCommand="RadGridOrder_ItemCommand">
                        <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="false" ReorderColumnsOnClient="true">
                            <Selecting AllowRowSelect="True" />
                            <Resizing EnableRealTimeResize="false" ResizeGridOnColumnResize="false" AllowColumnResize="false">
                            </Resizing>
                        </ClientSettings>
                        <MasterTableView Width="100%" DataKeyNames="OrderSubOrderID" ExpandCollapseColumn-ButtonType="ImageButton"
                            EditMode="InPlace" ExpandCollapseColumn-CollapseImageUrl="Img/minus.png" ExpandCollapseColumn-ExpandImageUrl="Img/Plus.png">
                            <DetailTables>
                                <telerik:GridTableView ShowHeadersWhenNoRecords="false" HorizontalAlign="Right" BorderWidth="1px"
                                    EnableNoRecordsTemplate="" Width="80%" runat="server">
                                    <ParentTableRelation>
                                        <telerik:GridRelationFields DetailKeyField="OrderSubOrderID" MasterKeyField="OrderSubOrderID" />
                                    </ParentTableRelation>
                                    <Columns>
                                        <telerik:GridBoundColumn HeaderText="ShippingStatus" DataField="Status" UniqueName="ShippingStatus">
                                        </telerik:GridBoundColumn>
                                        
                                        <telerik:GridBoundColumn HeaderText="textShipDate" DataField="ShippedOn" DataFormatString="{0:MM/dd/yyyy}"
                                            UniqueName="Timestamp">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn HeaderText="Quantitystr" DataField="Quantity" UniqueName="quantity">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </telerik:GridTableView>
                            </DetailTables>
                            <Columns>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" ItemStyle-Width="25" HeaderStyle-Width="25" />
                                <telerik:GridTemplateColumn HeaderText="ExternalItemstr" UniqueName="SKU">
                                    <ItemTemplate>
                                        <%#Eval("SKU")%>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="txtCouponCode" runat="server" Text='<%#Eval("SKU")%>'
                                            Width="95" />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn HeaderText="txtQuantityOrdered" DataField="Quantity" UniqueName="OrderedQuantity">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="txtQuantityShipped" DataField="Shipped 
Quantity" UniqueName="ShippedQuantity">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                        <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">
                        </ClientSettings>
                    </telerik:RadGrid>

Screen Short: please check attachment.

Please let me know if any one know solution.


 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Sep 2012, 11:41 AM
Hi,

This issue occurs when the RadGrid is not properly bound to data. If you are calling any methods for binding the data, please make sure that you call those methods inside the NeedDataSource event/not inside 'Not IsPostBack' condition in page load.

Please provide the code behind if it doesn't help.

Thanks,
Shinu.
0
MK
Top achievements
Rank 1
answered on 10 Sep 2012, 11:54 AM
Hi Shinu,

Thanks for reply.

I wrote a linq in "NeedDataSource" event as below:
protected void RadGridOrder_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (!e.IsFromDetailTable)
            {
                RadGridOrder.DataSource = (from o in ctx.Orders
                                           join os in ctx.OrderSubOrders on o.OrderID equals os.OrderID
                                           join ref_s in ctx.ref_OrderStatus on o.OrderStatusID equals ref_s.OrderStatusID
                                           where o.SequentialOrderNumber == SeqOrderNo
                                           select new
                                           {
                                               OrderSubOrderID = os.OrderSubOrderID,
                                               SequentialOrderNumber = o.SequentialOrderNumber,
                                               Status = ref_s.Name,
                                               //ShipmentStatus = ,
                                               SubOrderNumber = os.SubOrderNumber,
                                               Quantity = 10,
                                               ShippedOn = (Nullable<DateTime>)null
                                           }).ToList();
            }
        }

But you know we can't call Rebind method inside this event.

Still i have same issue.
0
MK
Top achievements
Rank 1
answered on 10 Sep 2012, 12:20 PM
Hi shinu,

I got root curse of my problem.

"SeqOrderNo" set 0 when i click for Edit.

Please can you tell me how can i manage this passing parameter?
 
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Sep 2012, 05:17 AM
Hi,

I guess 'SeqOrderNo' is an Integer variable. I need to know where you are assigning the value for 'SeqOrderNo' to replicate the issue. PostBack occur whenever you press an Edit button. Please prevent assigning the value inside 'Not IsPostBack' condition if its in page load event. Can you provide the  event in which you are assigning the value for 'SeqOrderNo'.

Thanks,
Shinu.
Tags
Grid
Asked by
MK
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
MK
Top achievements
Rank 1
Share this question
or