Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
195 views

Hello everybody,
I have encountered a problem in dealing with Radgrid,I have a aspx page with 3 UserControl inside of the page.This UserControls will be added at runtime(each in a tabstrip) and within the controls I have a Radgrid which have my ownn Custom logic and Insert,update and delete have been done in code-behind.
when I do Insert, it is perfect but when i refresh the page after doing insert,the InsertCommand of my RadGrid will be Fired again and insert the same record again.
Here is my Source Code


 

 

 

 

 

protected

 

 

void RadGridPanel_InsertCommand(object sender, GridCommandEventArgs e) 
  
   
  
{
  
   
  
   
  
GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem; 
  
   
  
   
  
   
  
GridEditableItem item = e.Item as GridEditableItem; 
  
   
  
   
  
   
  
tbl_Panel _tbl_Panel = new tbl_Panel(); 
  
   
  
item.UpdateValues(_tbl_Panel);
  
DbContext_Panel.AddTotbl_Panel(_tbl_Panel);
  
DbContext_Panel.SaveChanges();
  
}

 

<telerik:RadGrid  ID="RadGridPanel" CssClass="myRadGrid" GridLines="None" runat="server"  AllowAutomaticDeletes="True"
             PageSize="4"  AllowPaging="True" 
            AutoGenerateColumns="False"  OnItemUpdated="RadGridPanel_ItemUpdated"
            OnItemDeleted="RadGridPanel_ItemDeleted" OnItemInserted="RadGridPanel_ItemInserted" 
                OnDataBound="RadGridPanel_DataBound" AllowFilteringByColumn="True" 
                OnItemCreated="RadGridPanel_ItemCreated"
                oninsertcommand="RadGridPanel_InsertCommand" 
                OnUpdateCommand="RadGridPanel_UpdateCommand" 
                OnNeedDataSource="RadGridPanel_NeedDataSource" 
                oneditcommand="RadGridPanel_EditCommand" onitemdatabound="RadGridPanel_ItemDataBound" ondeletecommand="RadGridPanel_DeleteCommand"
                >
            <%--<PagerStyle Mode="NextPrevAndNumeric" />--%>
             <SelectedItemStyle Font-Names="Tahoma"  Font-Size="11px"   ForeColor="#8abe23"  /> 
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="PanelId"
                 HorizontalAlign="NotSet" AutoGenerateColumns="False"  Font-Names="Tahoma" EditMode="InPlace"  EditFormSettings-FormStyle-ForeColor="Black" Font-Size="11px">
                 <CommandItemTemplate>
                    <div style="padding: 5px 5px;" dir="rtl">
                   <asp:LinkButton ID="LinkButton2" runat="server" Font-Names="Tahoma" CommandName="InitInsert" Visible='<%# !RadGridPanel.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" src="../Images/Icons/AddRecord.gif" />اضافه كردن ركورد جديد</asp:LinkButton>  
                        <asp:LinkButton ID="LinkButton4" runat="server"  Font-Names="Tahoma" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Icons/Refresh.gif" />به روزآوري اطلاعات</asp:LinkButton>
                    </div>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn ConfirmText="آيا از حذف ركورد جاري مطمئنيد؟" ConfirmDialogType="RadWindow"
                        ConfirmTitle="حذف ركورد جاري" ButtonType="ImageButton" CommandName="Delete" Text="حذف"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn DataField="PanelName" HeaderText="پنل " SortExpression="PanelName"
                        UniqueName="PanelName" ColumnEditorID="GridTextBoxColumnPanelName">
                    </telerik:GridBoundColumn>
  
                    <telerik:GridBoundColumn DataField="Address" Display="False" EditFormColumnIndex="2" HeaderText=" آدرس "  SortExpression="Address"
                        UniqueName="Address" ColumnEditorID="GridTextBoxColumnAddress">
                    </telerik:GridBoundColumn>
  
                     <telerik:GridBoundColumn DataField="Tellphone" HeaderText="تلفن " SortExpression="Tellphone"
                        UniqueName="Tellphone" ColumnEditorID="GridTextBoxColumnTellphone">
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataField="SiteOwnerId" EditFormColumnIndex="0" HeaderText="شركت" UniqueName="SiteOwnerId" ListTextField="SiteOwnerName"
                     ListValueField="SiteOwnerId" ColumnEditorID="GridDropDownColumnSiteOwnerId">
                    </telerik:GridDropDownColumn>
                                        
                </Columns>
                <EditFormSettings ColumnNumber="3" CaptionDataField="PanelName"  CaptionFormatString="ويرايش اطلاعات" InsertCaption="" >
                   <FormTableItemStyle Wrap="True" ></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" 
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" Font-Names="Tahoma" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton" InsertText="ثبت پنل" UpdateText="ويرايش پنل"
                        UniqueName="EditCommandColumn1" CancelText="لغو ويرايش">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                </EditFormSettings>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>

 

Nizar
Top achievements
Rank 1
 answered on 03 Aug 2011
5 answers
117 views
Hi I want to store all the column values in all pages of radgrid in to list. I am storing Column Ids in the list...If the user sorts the radgrid by name...I have to store the column ids in the list in same sorting order

I am using itemdatabound .but it is storing the values in current page...but i need all the column values in all pages of radgrid...

Help is appreciated..
Thanks
Elliott
Top achievements
Rank 2
 answered on 03 Aug 2011
3 answers
168 views

I am working int he databound event trying to get the datakey value of my grid to populate my nestedview.  I have a tope level grid then a subgrid and then a nestedview of this.  how can i get the datakey of the second level grid to populate the nestedview values. I have tried this but no joy give me an error
item.OwnerTableView.DataKeyValues(item.ItemIndex)("intPositionId").ToString

 Protected Sub myGridDeploy_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myGridDeploy.ItemDataBound
        If TypeOf e.Item Is GridNestedViewItem Then
            Dim item As GridNestedViewItem = DirectCast(e.Item, GridNestedViewItem)

            sql = "Select mp.strSSN, si.FullName, si.strRank, si.Age, si.strPmos, si.strSmos, si.POSN_NBR_EXCESS_IND, si.SCTY_CLNC, si.ETS, si.strStatus, si.PHYS_PRFL_SER, si.intYearSvc, si.SRPDate, Deployable, si.Email " _
                & "From  tblPersonnel as mp LEFT JOIN vw_PersonrInfo  as si on si.strSSN = mp.strSSN where intPositionId = " & item.OwnerTableView.DataKeyValues(item.ItemIndex)("intPositionId").ToString

            myDataTable = New DataTable
            myDataTable = getData(sql)

            TryCast(item.FindControl("lblPerson"), Label).Text = myDataTable.Rows(0)(1)
            TryCast(item.FindControl("lblRank"), Label).Text = myDataTable.Rows(0)(2
            TryCast(item.FindControl("lblAge"), Label).Text = myDataTable.Rows(0)(3)
            TryCast(item.FindControl("lblPmos"), Label).Text = myDataTable.Rows(0)(4)
            If IsDBNull(myDataTable.Rows(0)(5)) Then
                myDataTable.Rows(0)(5) = "None"
            End If
            TryCast(item.FindControl("lblSmos"), Label).Text = myDataTable.Rows(0)(5)
            TryCast(item.FindControl("lblPosn"), Label).Text = myDataTable.Rows(0)(6)
            TryCast(item.FindControl("lblClear"), Label).Text = myDataTable.Rows(0)(7)
            TryCast(item.FindControl("lblEts"), Label).Text = myDataTable.Rows(0)(8)
            TryCast(item.FindControl("lblFullTime"), Label).Text = myDataTable.Rows(0)(9)
            TryCast(item.FindControl("lblPuhles"), Label).Text = myDataTable.Rows(0)(10)
            TryCast(item.FindControl("lblYrsActive"), Label).Text = myDataTable.Rows(0)(11)
            If IsDBNull(myDataTable.Rows(0)(12)) Then
                myDataTable.Rows(0)(12) = "None"
            End If
            TryCast(item.FindControl("lblDtSrp"), Label).Text = myDataTable.Rows(0)(12)
            TryCast(item.FindControl("lblDeplyable"), Label).Text = myDataTable.Rows(0)(13)
            TryCast(item.FindControl("lblEmail"), Label).Text = myDataTable.Rows(0)(14)

        End If
    End Sub

Pavlina
Telerik team
 answered on 03 Aug 2011
5 answers
172 views

What I have is a grid that contains a subgrid and then a nested view in the subgrid.  I am trying to get a hold of the datakey of the subgrid to populate the nestedview automatically,  Right now I have a static Id in the code to make sure it works but need to get the dynamic Id.  This was given to me before but did not work.  I got an error with it.  how can I get a hold of the datakey for the sub grid to populate the nested view of the subgrid.

Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim innergrid As RadGrid = DirectCast(sender, RadGrid)
        Dim nesteditem As GridNestedViewItem = DirectCast(innergrid.NamingContainer, GridNestedViewItem)
        Dim parentItem As GridDataItem = DirectCast(nesteditem.ParentItem, GridDataItem)
        Dim Id As String = parentItem.GetDataKeyValue("PositionId").ToString()
    End If
End Sub

Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'Telerik.Web.UI.GridNestedViewItem'.

 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'Telerik.Web.UI.GridNestedViewItem'.

Source Error:

Line 48:         If TypeOf e.Item Is GridDataItem Then
Line 49:             Dim innergrid As RadGrid = DirectCast(sender, RadGrid)
Line 50: Dim nesteditem As GridNestedViewItem = DirectCast(innergrid.NamingContainer








<telerik:RadGrid ID="myGridDeploy" runat="server" Width="95%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20">
                    <MasterTableView AutoGenerateColumns="false" DataKeyNames="intUnitMobId" HierarchyDefaultExpanded="false" HierarchyLoadMode="ServerBind"
                        BorderColor="#404040" Font-Size="12" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center"
                        GridLines="Both" BorderWidth="1px" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png"
                        ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png"><ItemStyle HorizontalAlign="Center" />
                        <AlternatingItemStyle BackColor="#B0C4DE"  HorizontalAlign="Center" />
                        <HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" />
                            <DetailTables>
                                 <telerik:GridTableView DataKeyNames="intPositionId" Name="myUnitPos" Width="100%" TableLayout="Fixed" BorderWidth="1px" CellPadding="6" Font-Size="10"
                                    AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" BorderColor="#404040" Font-Names="Veranda,arial,sans-serif" GridLines="Both" ExpandCollapseColumn-ButtonType="ImageButton"
                                    ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png">
                                    <ParentTableRelation>
                                        <telerik:GridRelationFields DetailKeyField="intUnitMobId" MasterKeyField="intUnitMobId" />
                                    </ParentTableRelation>
                                    <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="InnerSubHeaderStyle" />
                                    <ItemStyle CssClass="InnerSubItemStyle" HorizontalAlign="Center"  />
                                    <AlternatingItemStyle CssClass="InnerSubAlernatingItemStyle" HorizontalAlign="Center" />
                                        <NestedViewSettings>
                                            <ParentTableRelation>
                                                 <telerik:GridRelationFields DetailKeyField="intPositionId" MasterKeyField="intPositionId" />
                                            </ParentTableRelation>
                                        </NestedViewSettings>
                                        <NestedViewTemplate>
                                            <asp:Panel ID="pnlInfo" runat="server" BorderStyle="Double" BorderColor="#85A3E0" Width="90%">
                                                <table >
                                                    <tr>
                                                        <td><u>Soldier Information</u></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="height:5px"></td>
                                                    </tr>
                                                     <tr>
                                                        <td>
                                                            <b>Name:</b>&nbsp;<asp:Label ID="lblPersonnel" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Rank:</b>&nbsp;<asp:label ID="lblRank" runat="server"></asp:label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Age:</b>&nbsp;<asp:Label ID="lblAge" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>PMOS:</b>&nbsp;<asp:Label ID="lblPMOS" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>SMOS:</b>&nbsp;<asp:label ID="lblSMOS" runat="server"></asp:label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>POSN Excess:</b>&nbsp;<asp:Label ID="lblPOSN" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Clearance:</b>&nbsp;<asp:Label ID="lblClear" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>ETS\MRD:</b>&nbsp;<asp:label ID="lblEts" runat="server"></asp:label>
                                                         </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="height:5px"></td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <b>Full-Time:</b>&nbsp;<asp:Label ID="lblFullTime" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>PULHES:</b>&nbsp;<asp:Label ID="lblPuhles" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Yrs Active:</b>&nbsp;<asp:label ID="lblYrsActive" runat="server"></asp:label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>SRP Date:</b>&nbsp;<asp:Label ID="lblDtSrp" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Deployable:</b>&nbsp;<asp:label ID="lblDeplyable" runat="server"></asp:label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>DMOSQ:</b>&nbsp;<asp:label ID="lblDMOSQ" runat="server"></asp:label>&nbsp;&nbsp;&nbsp;&nbsp;
                                                            <b>Email:</b>&nbsp;<asp:Label ID="lblEmail" runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </asp:Panel>
                                        </NestedViewTemplate>
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="strPosnTitle" HeaderText="Title" />
                                            <telerik:GridBoundColumn DataField="strPara" HeaderText="Para" />
                                            <telerik:GridBoundColumn DataField="strLine" Headertext="Line" />
                                            <telerik:GridBoundColumn DataField="intPositionNum" HeaderText="Position" />
                                            <telerik:GridBoundColumn DataField="strGrade" HeaderText="Grade" />
                                            <telerik:GridBoundColumn DataField="strMos" HeaderText="Mos" />
                                            <telerik:GridBoundColumn DataField="strASI" HeaderText="ASI" />
                                            <telerik:GridBoundColumn DataField="Filled" HeaderText="Filled" />
                                            <telerik:GridTemplateColumn HeaderText="Add">
                                                <ItemTemplate>
                                                    <asp:ImageButton runat="server" ID="imgAdd"  CommandArgument='<%# bind("intPositionId") %>' CommandName="AddSoldier" ImageUrl="~/Images/29.png" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                             <telerik:GridTemplateColumn HeaderText="Add">
                                                <ItemTemplate>
                                                    <asp:ImageButton runat="server" ID="imgEdit"  CommandArgument='<%# bind("intPositionId") %>' CommandName="EditSoldier" ImageUrl="~/Images/Edit_icon.png" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                 </telerik:GridTableView>
                             </DetailTables>
                            <Columns>
                                <telerik:GridBoundColumn DataField="strUIC" HeaderText="UIC" />
                                <telerik:GridBoundColumn DataField="strDeployment" HeaderText="Deployment" />
                                <telerik:GridBoundColumn DataField="strAttchUic" HeaderText="BN UIC" />
                                <telerik:GridBoundColumn DataField="dtDeploy" Headertext="DT_Deploy" />
                                <telerik:GridBoundColumn DataField="dtDemob" HeaderText="DT_Demob" />
                                <telerik:GridTemplateColumn HeaderText="Import Soldiers">
                                    <ItemTemplate>
                                            <asp:ImageButton runat="server" ID="imgAddPosition"  CommandArgument='<%# bind("intUnitMobId") %>' CommandName="AddMul" ImageUrl="~/Images/29.png" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="Assign" HeaderText="Assigned" />
                                <telerik:GridBoundColumn DataField="nonAssign" HeaderText="Fill" />
                                <telerik:GridBoundColumn DataField="Total" HeaderText="Total" />
                            </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

 

 

Protected Sub myGridDeploy_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myGridDeploy.ItemDataBound

        If TypeOf e.Item Is GridDataItem Then
            Dim innergrid As RadGrid = DirectCast(sender, RadGrid)
            Dim nesteditem As GridNestedViewItem = DirectCast(innergrid.NamingContainer, GridNestedViewItem)
            Dim parentItem As GridDataItem = DirectCast(nesteditem.ParentItem, GridDataItem)
            Dim Id As String = parentItem.GetDataKeyValue("PositionId").ToString()
        End If

        If TypeOf e.Item Is GridNestedViewItem Then
            Dim item As GridNestedViewItem = DirectCast(e.Item, GridNestedViewItem)
          
            sql = "Select mp.strSSN, si.FullName, si.strRank, si.Age, si.strPmos, si.strSmos, si.POSN_NBR_EXCESS_IND, si.SCTY_CLNC, si.ETS, si.strStatus, si.PHYS_PRFL_SER, si.intYearSvc, si.SRPDate, Deployable, " _
                & "Case when mp.intDMOSQ = 1 then 'YES' ELSE 'NO' END intDMOSQ, si.Email " _
                & "From  tblMobUnitPersonnel as mp LEFT JOIN vw_SoldierInfo  as si on si.strSSN = mp.strSSN where intPositionId = " & Id

            myDataTable = New DataTable
            myDataTable = getData(sql)

            TryCast(item.FindControl("lblPersonnel"), Label).Text = myDataTable.Rows(0)(1)
            TryCast(item.FindControl("lblRank"), Label).Text = myDataTable.Rows(0)(2)
            TryCast(item.FindControl("lblAge"), Label).Text = myDataTable.Rows(0)(3)
            TryCast(item.FindControl("lblPmos"), Label).Text = myDataTable.Rows(0)(4)
            If IsDBNull(myDataTable.Rows(0)(5)) Then
                myDataTable.Rows(0)(5) = "None"
            End If
            TryCast(item.FindControl("lblSmos"), Label).Text = myDataTable.Rows(0)(5)
            TryCast(item.FindControl("lblPosn"), Label).Text = myDataTable.Rows(0)(6)
            TryCast(item.FindControl("lblClear"), Label).Text = myDataTable.Rows(0)(7)
            TryCast(item.FindControl("lblEts"), Label).Text = myDataTable.Rows(0)(8)
            TryCast(item.FindControl("lblFullTime"), Label).Text = myDataTable.Rows(0)(9)
            TryCast(item.FindControl("lblPuhles"), Label).Text = myDataTable.Rows(0)(10)
            TryCast(item.FindControl("lblYrsActive"), Label).Text = myDataTable.Rows(0)(11)
            If IsDBNull(myDataTable.Rows(0)(12)) Then
                myDataTable.Rows(0)(12) = "None"
            End If
            TryCast(item.FindControl("lblDtSrp"), Label).Text = myDataTable.Rows(0)(12)
            TryCast(item.FindControl("lblDeplyable"), Label).Text = myDataTable.Rows(0)(13)
            TryCast(item.FindControl("lblDMOSQ"), Label).Text = myDataTable.Rows(0)(14)
            TryCast(item.FindControl("lblEmail"), Label).Text = myDataTable.Rows(0)(15)

        End If
    End Sub

Pavlina
Telerik team
 answered on 03 Aug 2011
3 answers
103 views
Hi,

I create dynamic Link Button in my grid depending on DateFields.

I have had a TemplateColumn like this
<telerik:GridTemplateColumn HeaderText="Action" UniqueName="tplColAction">
                    <ItemTemplate>
                        <asp:Panel ID="pnlActionStatut" runat="server" HorizontalAlign="left">
                        </asp:Panel>
                    </ItemTemplate>
</telerik:GridTemplateColumn>

In my code behind i do that

protected void rdGridOpportunite_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.ItemType != GridItemType.Item && e.Item.ItemType != GridItemType.AlternatingItem) return;
  
        //Get Object Entity
        OpportuniteEntity opp = e.Item.DataItem as OpportuniteEntity;
        if (opp == null) return;
  
        //Get Panel
        Control pnl = e.Item.FindControl("pnlActionStatut");
        if (!(pnl is Panel)) return;
          
        //Get All statut associate of this statut
        List<TypeStatutOpportuniteEntity> statuts = TypeManager.GetStatutAssocieOfStatut(opp.TypeStatut.IDType, Profile.InstanceID).ToList();
        if (statuts.Count == 0) return;
  
        LinkButton lbAction;
          
        //Create LinkButton for each Statut  
        statuts.ForEach(s =>
            {
                lbAction = new LinkButton();
                lbAction.Text = "--> " + s.Libelle;
                lbAction.Click += new EventHandler(lbAction_Click);
                lbAction.CommandArgument = string.Format("{0};{1}", opp.ID, s.IDType);
                lbAction.ID = string.Format("lnkBtn{0}{1}", opp.ID, s.IDType);
                pnl.Controls.Add(lbAction);
                pnl.Controls.Add(new Label() { Text = "<br />" });
            }
        );
    }

My Grid can be expan or collapse and when I Expand or collapse i Lost my control ...
Ditto When I click on LinkButton i lost control too and i can't start GridCommand and lbAction Event click

I have try to make the same code on ItemCreated but the result is the same.

How I can keep my control ??

Thank you.
PS : Sorry for my English

Pavlina
Telerik team
 answered on 03 Aug 2011
2 answers
188 views
hi,

Hello, after populated the grid with a class

<telerik:RadGrid ID="radGridListTypeRoom" runat="server" 
                            AllowPaging="false"  
                            Width="100%" 
                            AutoGenerateColumns="false" 
                            OnDetailTableDataBind="radGridListTypeRoom_DetailTableDataBind">
                            <MasterTableView DataKeyNames="hotelRoomTypeId" DataMember="MasterGrid" Name="TypeRoom" Width="100%">
                                <DetailTables>
                                    <telerik:GridTableView DataKeyNames="hotelRoomTypeId" Name="DetailPrice" Width="100%">
                                         <Columns>
                                            <telerik:GridTemplateColumn HeaderText="Username">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblName" runat="server" Text='<%# Bind("name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </telerik:GridTableView></DetailTables>
                                <Columns>
                                    <telerik:GridBoundColumn DataField="name" HeaderText="Tipo di stanza">
                                    </telerik:GridBoundColumn>    
                                    <telerik:GridBoundColumn DataField="isAvailable" HeaderText="Disponibilità">
                                    </telerik:GridBoundColumn>                                    
                                </Columns>
                            </MasterTableView>
                            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                        </telerik:RadGrid>



radGridListTypeRoom.DataSource = hotel.RoomTypes;
radGridListTypeRoom.DataBind();

when fired the event to view the detail (Hierarchy)  how can i retrieve the object class?

        protected void radGridListTypeRoom_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
 
            RoomType roomType = (RoomType)dataItem.DataItem;
 
            switch (e.DetailTableView.Name)
            {
                case "DetailPrice":
                    {
 
                        break;
                    }
            }
        }


why dataitem.dataitem is null ?

Thanks for the collaboration and sorry for bad eng.
Pavlina
Telerik team
 answered on 03 Aug 2011
4 answers
81 views
OK not sure if my title was too descriptive or not, but I am rather new to Talerik so this could just be a basic question. We are using a rad window for all our messages back to a user (process succesful, or failed, and etc.) some of our recent changes added user controls to a parent page and those need to now call the rad window that is on the aspx page of the parent page and pass the message to the user. How do we do this?

Here is current code on the parent page code behind when opening the window:
if (isSuccess)
{
message = "blah blah blah was successful, now do blah blah blah";
MessageRadWindow.NavigateUrl = "MessageAlert.aspx?message=" + encrypt.encrypt(message);
MessageRadWindow.Visible = true;
MessageRadWindow.VisibleOnPageLoad = true;
}

Now, that works well for what the message window is needed to do, however I am unsure how to call that same MessageRadWindow from the user control that is now embeded in that same page via a page.loadcontol method. I have attemtped different .GetControl methods and a couple things I found on the forums here and can neve get it to compile because it isn't finding the parent page controls for some reason. I am getting things like:
Error 281 The name 'RadAjaxManager1' does not exist in the currentcontext C:\_tfs\xxxx\xxxx\xxxx\Schedulexxxx.ascx.cs 81 14 xxxx_admin

What am I missing? Does the usercontrol need it's own ajax manager, and if so how do I get it there because I get errors stating cannot have more than on ajax manager on a page when I attempted to add one tot he user control?
Marin Bratanov
Telerik team
 answered on 03 Aug 2011
4 answers
66 views
Is it possible to change the text of the Mode Tabs?  For example, inside of the tab saying "Design" I'd like it to say "Edit".
Matt
Top achievements
Rank 1
 answered on 03 Aug 2011
4 answers
108 views
Hi,

I have a RadRotator that shows the list of images and the rotator scrolls from top to bottom. I just want to illustrate my problem with an example. I have 5 images bound to the rotator control. At any point of time, only 2 images will show up. i scroll down and select image 4. I have OnItemClick event that does some action based on the image that i select. My objective is: I would want to retain the selection of 4th image (at least from the UI perspective). What is happening is: after the postback event, selection is lost in the radrotator event and rotator resets and shows the first item. Is there a way that i can retain the same image? I tried doing partial postback using AJAX to ensure rotator control is not updated. But even this didn't help. any help on this?

<telerik:RadRotator ID="thumbRotator" runat="server" RotatorType="Buttons" WrapFrames="false"
                        FrameDuration="1" ScrollDirection="Up, Down" OnItemClick="thumbRotator_ItemClick"
                        EnableEmbeddedSkins="false" Skin="FAPortalRotator" CssClass="rotatorVertical"
                        ItemWidth="300px" ItemHeight="225px">
                        <ItemTemplate>
                            <asp:Image ID="chartImage" runat="server" AlternateText="Image" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageURL")%>'
                                CssClass="thumbnail" />
                        </ItemTemplate>
                        <ControlButtons LeftButtonID="img_left" RightButtonID="img_right" />
                    </telerik:RadRotator>


Regards,
Kishan G K
Kishan Gandikota
Top achievements
Rank 1
 answered on 03 Aug 2011
3 answers
70 views
I have a radgrid inside a radajaxpanel.  outside of the ajaxpanel I have an instance of a usercontrol that has two buttons: one button exports the radgrid to excel and the other exports the radgrid to a pdf doc.  I can get the code to execute and open the results of the radgrid in a new window either excel or PDF, but when I close the new window and return to the parent page, the mouse pointer is an hourglass until I either manually refresh the page, or click a different button on the page that does a postback.  How do I get the hourglass to go away and display the normal mouse pointer?
Pavlina
Telerik team
 answered on 03 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?