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

Radgrid visible problem

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 27 Sep 2011, 04:45 PM
Hello
I have a radgrid in my form.
I also have a radiobutton that control if I want to see the radgrid or not
If Me.RBDestination.SelectedValue = 0 Then 'simple
          Me.TrMultiple.Visible = False
      ElseIf Me.RBDestination.SelectedValue = 1 Then 'multiple
          Me.TrMultiple.Visible = True
      End If
My radgrid is in the TrMultiple <tr>
On the page load I do
If Not IsPostBack = True Then
          RBDestination.SelectedValue = 0
          RBDestination_SelectedIndexChanged(Me, EventArgs.Empty)
  End If
 And my RadioButton looks like this:
<asp:RadioButtonList ID="RBDestination" runat="server" BorderColor="Black" BorderWidth="1" AutoPostBack="true">
            <asp:ListItem Value="0">Destination simple</asp:ListItem>
             <asp:ListItem Value="1">Destination multiple</asp:ListItem>
 </asp:RadioButtonList>
and my radgrid:
<tr id="TrMultiple" runat="server" >
       <td></td>
       <td>
              <telerik:RadGrid 
                   ID="RadGrid2" 
                   Skin="Vista" 
                   runat="server" 
                   ShowFooter="true" 
                  CommandItemStyle-HorizontalAlign="Center" Width="200px">  
                                   
                   <MasterTableView 
                        ShowFooter="true" 
                        CommandItemDisplay="bottom" 
                        EditMode="InPlace" >  
                       <CommandItemTemplate>
                              <asp:LinkButton ID="LinkButton1" CommandName="CalculDistance" Runat="server" CssClass="TexteBlanc16">Calculer</asp:LinkButton>
                       </CommandItemTemplate>
                      <Columns>                     
                           <telerik:GridTemplateColumn UniqueName="CodePostal" HeaderText="Destinations">  
                                 <ItemTemplate>  
                                      <asp:DropDownList ID="LstCodePostal" runat="server"></asp:DropDownList>
                                 </ItemTemplate>  
                          </telerik:GridTemplateColumn>  
                      </Columns>  
               </MasterTableView>  
                                     
     </telerik:RadGrid>

When I click on the radio button to put it visible (value = 1) then I see a little blue line as my radgrid seems to be empty. However, If in my page load I put the radiobutton value to 1, I see my radgrid as It should be..And after that, if I select the value 0 of my radio button and reselect the value 1 to make appear my grid, it shows my grid correctly.
It seems to happens only when I put the radgrid visible to false on page load...
how can i fix it?
Thank you

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Sep 2011, 07:08 AM
Hello Myriam,

I tried the following code snippet and it worked on my end.
VB:
protected void Page_Load(object sender, EventArgs e)
{
 If Not (IsPostBack = True) Then
    RBDestination.SelectedValue = "0"
    RBDestination_SelectedIndexChanged(Me, EventArgs.Empty)
 End If
}
protected void RBDestination_SelectedIndexChanged(object sender, EventArgs e)
{
  If RBDestination.SelectedValue.ToString() = "0" Then
    Me.TrMultiple.Visible = False
  ElseIf RBDestination.SelectedValue.ToString() = "1" Then
    Me.TrMultiple.Visible = True
  End If
}

Thanks,
Princy
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or