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

radgrid.visible=true - I can't see my rows

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 23 Sep 2009, 05:29 PM
Hello
I have radiobuttons in my webform. I also have a radgrid which is visible=false when I load the form.  When I select a choice on the radiobutton, I want my radgrid become visible. This is working fine. But I lose all rows that I have in my radgrid. I can only see a light blue horizontal line. Nothing appear in the radgrid. When I don't put the radgrid.visible=false I see my rows in my grid...
Here is my code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="FEN_CHANGEMENT_INSTALLATION_LOGICIELLE.aspx.vb" Inherits="Interface_RT.FEN_CHANGEMENT_INSTALLATION_LOGICIELLE" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register TagPrefix="header" TagName="a" Src="Template.ascx" %>   
<%@ Register TagPrefix="header" TagName="b" Src="TemplateFin.ascx" %>   
<!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>Assistance TI</title> 
     <link href="Style.css" type="text/css" rel="stylesheet"/>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
    <header:a id="A1" runat="server"></header:a> 
     <asp:scriptmanager ID="ScriptManager1" runat="server" ></asp:scriptmanager> 
           <br /> 
      <table width="70%" align=center>   
            <tr> 
               <td colspan=2 align=center><asp:Label runat=server ID="LbTitre" Text="Installation logiciel" CssClass="TexteBlanc16center"></asp:Label><br /><br /></td>  
            </tr> 
            <tr> 
                <td align="right" width="40%"><asp:Label runat=server ID="LbCodeUtilisateur" Text="Logiciel: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left" width="60%"><telerik:RadTextBox ID="TxtLogiciel" runat="server" Width="200px"></telerik:RadTextBox></td>  
            </tr> 
            <tr> 
                <td align="right"><asp:Label runat=server ID="Label1" Text="Servant à: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left">  
                    <asp:RadioButtonList runat=server ID="RbntListServant"  Width="225px"  CssClass="TexteBlanc12Left" BorderColor=White BorderWidth=1 > 
                        <asp:ListItem Text="L'administratif" Value=1 ></asp:ListItem> 
                        <asp:ListItem Text="La pédagogie" Value=2 ></asp:ListItem> 
                    </asp:RadioButtonList> 
                </td> 
            </tr> 
            <tr> 
                <td align="right"><asp:Label runat=server ID="LbLocal" Text="Local(s): " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left"><telerik:RadTextBox ID="TxtLocal" runat="server" Width="200px"></telerik:RadTextBox></td>  
            </tr> 
            <tr> 
                <td align="right"><asp:Label runat=server ID="LbPersonneContact" Text="Nom de la personne contact: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left"><telerik:RadTextBox ID="TxtPersonneContact" runat="server" Width="200px"></telerik:RadTextBox></td>  
            </tr> 
             <tr> 
                <td align="right"><asp:Label runat=server ID="LbPosteTelephonique" Text="Poste téléphonique: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left"><telerik:RadTextBox ID="TxtPosteTelephonique" runat="server"></telerik:RadTextBox></td>  
            </tr> 
            <tr> 
                <td align="right"><asp:Label runat=server ID="LbNoCSBE" Text="No CSBE: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left" > 
                     <asp:RadioButtonList runat=server ID="RbntListNoCSBE" AutoPostBack=true  Width="225px" BorderColor=White BorderWidth=1  CssClass="TexteBlanc12Left">  
                        <asp:ListItem Text="Tous" Value=1 ></asp:ListItem> 
                        <asp:ListItem Text="Poste(s)" Value=2 ></asp:ListItem> 
                    </asp:RadioButtonList> 
                </td> 
            </tr> 
            <tr  id="TableRadgrid" runat=server>  
                <td valign=top align=right><asp:Label runat=server ID="Label3" Text="Postes(#CSBE): " CssClass="TexteBlanc12"></asp:Label></td>  
                <td> 
                    <telerik:RadGrid   
                        ID="RadGrid_Postes"   
                        Skin="Vista"   
                        runat="server">    
                        <MasterTableView   
                            EditMode="InPlace">    
                            <Columns>                       
                                <telerik:GridTemplateColumn UniqueName="NoCSBE" HeaderText="# CSBE">    
                                    <ItemTemplate>    
                                        <asp:TextBox ID="TxtNoCsbe" runat="server"></asp:TextBox>    
                                    </ItemTemplate>    
                                </telerik:GridTemplateColumn>    
                           </Columns>    
                       </MasterTableView>    
                    </telerik:RadGrid>   
                     <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Ajouter une ligne" /> 
                </td> 
            </tr> 
            <tr> 
                <td align="right"><asp:Label runat=server ID="LbLicence" Text="Avez vous la licence?: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left">  
                    <asp:RadioButtonList runat=server Width="225px" AutoPostBack=true ID="RbntListLicence" BorderColor=White BorderWidth=1   CssClass="TexteBlanc12Left">  
                        <asp:ListItem Text="Non" Value=1></asp:ListItem> 
                        <asp:ListItem Text="Oui" Value=2></asp:ListItem> 
                    </asp:RadioButtonList> 
                 </td> 
             </tr> 
             <tr visible=false id="TablePB" runat=server>  
                 <td align=right>  
                     <asp:Label runat=server ID="LbPB" Text="Poste Budgétaire: " CssClass="TexteBlanc12"></asp:Label> 
                 </td> 
                 <td align=left>  
                     <telerik:RadTextBox ID="TxtPosteBudgetaire" runat="server"></telerik:RadTextBox> 
                 </td> 
             </tr> 
             <tr visible=false id="TableNombre" runat=server>  
                 <td align=right>  
                     <asp:Label runat=server ID="Label2" Text="Quel genre de licence?: " CssClass="TexteBlanc12"></asp:Label> 
                 </td> 
                 <td  align=left>  
                     <asp:RadioButtonList  runat=server ID="RbntListEtabCommNbre" Width="225px" AutoPostBack=true  CssClass="TexteBlanc12Left" BorderColor=White BorderWidth=1>  
                         <asp:ListItem Text="Établissement/Commission" Value=1></asp:ListItem> 
                         <asp:ListItem Text="Nombre" Value=2></asp:ListItem> 
                     </asp:RadioButtonList> 
                      
                 </td> 
            </tr> 
            <tr visible=false id="TableNombre2" runat=server>  
                <td align=right>  
                    <asp:Label runat=server ID="LbNombre" Text="Nombre de licences: " CssClass="TexteBlanc12"></asp:Label> 
                </td> 
                <td align=left>  
                    <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox> 
                </td> 
            </tr> 
                      
            <tr> 
                <td align="right" valign="top"><asp:Label runat=server ID="LbDescriptionProbleme" Text="Description du problème: " CssClass="TexteBlanc12"></asp:Label></td>  
                <td align="left"><telerik:RadTextBox ID="TxtDescriptionProbleme" TextMode="MultiLine" Height="150px" Width="450px" runat="server"></telerik:RadTextBox></td>  
            </tr> 
            <tr> 
                <td>&nbsp;<br /></td>  
                <td align=left ><br /><asp:Button runat=server ID="BtnSauvegarder" Text="Sauvegarder" /></td>  
            </tr> 
        </table> 
     <header:b id="A2" runat="server"></header:b> 
    </div> 
    </form> 
</body> 
</html> 
 

Imports Telerik.Web.UI  
Partial Public Class FEN_CHANGEMENT_INSTALLATION_LOGICIELLE  
    Inherits System.Web.UI.Page  
    Public fonctionsvbs As New fonctionsvb  
    Public liste As New List(Of String)  
    Public listcount As Integer 
    Public dt As DataTable  
 
    Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
 
        If Not IsPostBack Then 
 
            dt = New DataTable()  
            dt.Columns.Add(New DataColumn("RowNumber"GetType(String)))  
 
            'Ajouter le nombre de colonne au début  
            AddRow(dt)  
            AddRow(dt)  
            AddRow(dt)  
            'Me.RadGrid_Postes.Visible = False  
            Me.RadGrid_Postes.Enabled = False 
        End If 
 
    End Sub 
 
    Private Sub BtnSauvegarder_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles BtnSauvegarder.Click  
        Dim sujet As String 
        Dim message As String 
        sujet = "Poste élève portable" 
        message = "$ rt create –t ticket" & _  
                "<br>Queue: " & Session("sFile") & _  
                "<br>Subject: Poste élève portable" & _  
                "<br>Status: new" & _  
                "<br>Content:Local:" & Me.TxtLocal.Text & " Problème:" & Me.TxtDescriptionProbleme.Text & _  
                "<br>ENDOFCONTENT()" & _  
                "<br>Due:" & _  
                "<br>Starts:" & _  
                "<br>Started:" & _  
                "<br>Resolved:" & _  
                "<br>Owner:  " & Session("sPropriétaire") & _  
                "<br>Requestor: " & Session("sUsager") & _  
                "<br>Cc:" & _  
                "<br>AdminCc:" & _  
                "<br>TimeWorked:" & _  
                "<br>TimeEstimated:" & _  
                "<br>TimeLeft:" & _  
                "<br>Priority: " & _  
                "<br>InitialPriority:" & _  
                "<br>FinalPriority:" & _  
                "<br>DependsOn:" & _  
                "<br>RefersTo:" & _  
                "<br>ReferredToBy:" & _  
                "<br>Children:" & _  
                "<br>DependsOnBy:" & _  
                "<br>Parents:" 
        fonctionsvbs.CreerRequis(sujet, message)  
    End Sub 
 
    Private Sub RbntListLicence_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles RbntListLicence.SelectedIndexChanged  
        If RbntListLicence.SelectedValue = 1 Then 'non  
            Me.TablePB.Visible = True 
            Me.TableNombre.Visible = False 
            Me.TableNombre.Visible = False 
        ElseIf RbntListLicence.SelectedValue = 2 Then 'oui  
            Me.TablePB.Visible = False 
            Me.TableNombre.Visible = True 
        End If 
 
    End Sub 
 
    Private Sub RbntListEtabCommNbre_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles RbntListEtabCommNbre.SelectedIndexChanged  
        If RbntListEtabCommNbre.SelectedValue = 1 Then 'Établissement/Commission  
            Me.TableNombre2.Visible = False 
        ElseIf RbntListEtabCommNbre.SelectedValue = 2 Then 'Nombre  
            Me.TableNombre2.Visible = True 
        End If 
    End Sub 
    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As EventArgs)  
        Dim countitem As Integer 
        Dim dt As DataTable = DirectCast(ViewState("dt"), DataTable)  
 
        countitem = RadGrid_Postes.Items.Count  
        Dim cpt As Integer = 0  
        For Each Item As GridDataItem In RadGrid_Postes.Items  
 
            Dim txtcode As TextBox = DirectCast(Item("NoCsbe").FindControl("TxtNoCsbe"), TextBox)  
            If Not (txtcode.Text Is NothingAnd txtcode.Text <> "" Then 
                liste.Add(txtcode.Text)  
 
            End If 
 
        Next 
        ViewState("dt") = AddRow(dt)  
        listcount = liste.Count  
 
        RadGrid_Postes.Rebind()  
        While cpt < listcount  
            Dim txtcode As TextBox = DirectCast(RadGrid_Postes.Items(cpt)("NoCsbe").FindControl("TxtNoCsbe"), TextBox)  
            txtcode.Text = liste.Item(cpt)  
            cpt = cpt + 1  
        End While 
    End Sub 
 
    Private Sub RadGrid_Postes_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid_Postes.NeedDataSource  
        If Not IsPostBack Then 
            dt = AddRow(dt)  
            ' call the method to create row   
            ViewState("dt") = dt  
        End If 
        dt = DirectCast(ViewState("dt"), DataTable)  
        RadGrid_Postes.DataSource = dt  
    End Sub 
 
    Private Function AddRow(ByVal dt As DataTable) As DataTable  
        ' method to create row   
        Dim dr As DataRow = dt.NewRow()  
        dr("RowNumber") = "" 
        dt.Rows.Add(dr)  
        Return dt  
    End Function 
 
    Private Sub RadGrid_Postes_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadGrid_Postes.PreRender  
        '  RadGrid_Postes.MasterTableView.RenderColumns(3).Display = False  
 
    End Sub 
 
    Private Sub RbntListNoCSBE_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs) Handles RbntListNoCSBE.SelectedIndexChanged  
        If RbntListNoCSBE.SelectedValue = 1 Then 'Tous  
            'Me.TableRadgrid.Visible = False  
            Me.RadGrid_Postes.Enabled = False 
        ElseIf RbntListNoCSBE.SelectedValue = 2 Then 'Postes  
            'Me.TableRadgrid.Visible = True  
            Me.RadGrid_Postes.Enabled = True 
        End If 
    End Sub 
End Class 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 24 Sep 2009, 04:21 PM
Hi Myriam,

RadGrid fires the NeedDataSource event each time it needs to be bound to a data source. If, at the time of the event, the DataSource property is not set to a valid data source object, the grid will not behave correctly.
Please note that you should never call the Rebind() method in a NeedDataSource event handler.
For more information about advanced Data- binding, please refer to the following help article:
http://www.telerik.com/help/aspnet-ajax/grdadvanceddatabinding.html

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or