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

[Solved] Edit command makes grid disappear.

1 Answer 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Temp
Top achievements
Rank 1
Temp asked on 20 Jun 2008, 07:15 AM

I have a very simple scenario here, with a Tab strip with two tabs, that changes the datasource of a grid (so it would load different categories of products for example). I am trying to get this to work, and it seems to go well until I click edit to edit a row, because then the whole grid disappears.

Can someone please help me with this. It is very simple I am sure.Where am I going wrong?

// Test.aspx.cs (codebehind)  
using System;  
using System.Collections;  
using System.Configuration;  
using System.Data;  
using System.Linq;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Xml.Linq;  
 
using Mariner7.TalentManager;  
using Telerik.Web.UI;  
 
public partial class Test : System.Web.UI.Page  
{  
 
 
    public int OrgID { get; set; }  
    public string Category { get; set; }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if(!Page.IsPostBack)  
        {  
            Category = RadTabStrip1.Tabs[0].Text;  
            RadGrid1.DataSource = GetDataSource();  
            RadGrid1.DataBind();  
        }  
    }  
 
    protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)  
    {  
        Category = e.Tab.Text;  
        Refresh();  
    }  
 
    public void Refresh()  
    {  
        RadGrid1.DataSource = null;  
        RadGrid1.DataSource = GetDataSource();  
        RadGrid1.DataBind();  
    }  
 
    private object GetDataSource()  
    {  
        ArrayList list = new ArrayList();  
        switch (Category)  
        {  
            case "Cat1":  
                list.Add("item 10");  
                list.Add("item 11");  
                break;  
            case "Cat2":  
                list.Add("item 20");  
                list.Add("item 21");  
                break;  
            default:  
                break;  
        }  
        return list;  
    }  
      
}  
 
--Test.aspx  
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register assembly="RadTabStrip.Net2" namespace="Telerik.WebControls" tagprefix="radTS" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>Untitled Page</title> 
    <script type="text/javascript">  
      function pageLoad() {  
      }  
    </script> 
</head> 
<body> 
    <form id="form1" runat="server">  
      
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadTabStrip1">  
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadTabStrip1"/>  
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
      
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" OnTabClick="RadTabStrip1_TabClick" Orientation="HorizontalTop">  
        <Tabs> 
            <telerik:RadTab Text="Cat1"/>  
            <telerik:RadTab Text="Cat2"/>  
        </Tabs> 
    </telerik:RadTabStrip> 
 
    <telerik:RadGrid   
            ID="RadGrid1"   
            runat="server"   
            GridLines="Horizontal"   
            AutoGenerateEditColumn="true"   
            Skin="WebBlue" > 
        <MasterTableView  AutoGenerateColumns="True" EditMode="InPlace" TableLayout="Auto">  
            <RowIndicatorColumn Visible="False">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn Visible="False" Resizable="False">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
            </Columns> 
            <EditFormSettings> 
                <PopUpSettings ScrollBars="None"></PopUpSettings> 
            </EditFormSettings> 
        </MasterTableView> 
    </telerik:RadGrid> 
      
    </form> 
</body> 
</html> 
 
 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jun 2008, 08:03 AM
Hi Temp,

Try binding the Grid using AdvanceDataBinding techniques.

Advanced data-binding
Form template edit form

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