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

TileList selection changed is not fired on the second post back.

1 Answer 23 Views
TileList
This is a migrated thread and some comments may be shown as answers.
Tung
Top achievements
Rank 1
Tung asked on 23 Jun 2014, 08:46 AM
I am having a tilelist with the following settings:
<telerik:RadTileList runat="server" ID="RadTileList1" AppendDataBoundItems="true" SelectionMode="Multiple"
    TileRows="1" 
    Height="100px" Width="980px"  ScrollingMode="None"
    <DataBindings>
        <CommonTileBinding TileType="RadImageAndTextTile" DataGroupNameField="TOOL" />
        <ImageAndTextTileBinding DataTextField="LOT_ID" />
        <TilePeekTemplate>
            <div class="peekTemplateClass">
                <strong>Product:</strong>
                <%#DataBinder.Eval(Container.DataItem, "PRODUCT")%>
                <br />
            </div>
        </TilePeekTemplate>
    </DataBindings>
    <Groups>
        <telerik:TileGroup Name="24575">
            <telerik:RadContentTemplateTile ID="RadContentTemplateTile27" runat="server" CssClass="noHover"
                Height="75px">
                <ContentTemplate>
                    <div class="innerTitle">
                        <strong>24575</strong>
                    </div>
                </ContentTemplate>
            </telerik:RadContentTemplateTile>
        </telerik:TileGroup>
    </Groups>
</telerik:RadTileList>

And in the code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
 
public partial class StockerViewMonitor : System.Web.UI.Page
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            FcDAL.SetupOracleDBConnection(Helper.GetScConnStr());
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                LoadList();
         }
  
        protected void fetchButton_OnClick(object sender, EventArgs e)
        {
            List<RadBaseTile> selectedTiles = RadTileList1.GetSelectedTiles()
 
            DbCommand[] deleteCmds = new DbCommand[selectedTiles.Count];
            int j = 0;
            foreach (RadBaseTile tile in selectedTiles)
            {
                deleteCmds[j] = FcDAL.CreateDbCommand("DELETE A_GF_TOOL_LOT WHERE LOT_ID=:0", ((RadImageAndTextTile)tile).Text);
                j++;
            }
            FcDAL.ExecuteTransaction(deleteCmds);
                LoadList();
  
        }
       
        private DataTable GetLotList(int toolID)
        {
               // Get retRetable
           return retTable;
        }
  
        private void LoadList()
        {
            RadTileList1.DataSource = GetLotList(24575);
            RadTileList1.DataBind();
        }
        }
    }

When I first load the page and selected some tiles and click on the fetch button for the first time, I can get all the the tiles that have been selected and delete those records from DB. 

The problem is, after that, if I select some of other tiles, and click fetch button, the selected tiles are not recognized any more, and hence I couldn't delete them from DB.

I suspect the postdata in the post back request is different from the data stored in ViewState, thus making the selection changed event not fired. I tried to call the LoadList() method at Page_Init() and Page_Onload bit they seemed not working.

Is there any wrong understanding ? And how do I resolve the above problem?
Thank you very much

*Note: Some of the irrelevant codes are removed from the above code snippet.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 23 Jun 2014, 01:08 PM
Hi Tung,

Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadTileList runat="server" ID="PurchaseTileList" Width="900px" TileRows="1"
    SelectionMode="Multiple" EnableDragAndDrop="True">
    <DataBindings>
        <CommonTileBinding TileType="RadImageAndTextTile" Shape="Square" DataGroupNameField="ContactTitle" />
        <ImageAndTextTileBinding DataTextField="CustomerID" />
        <TilePeekTemplate>
            <div class="peekTemplateClass">
                <strong>Phone:</strong>
                <%#DataBinder.Eval(Container.DataItem, "Phone")%>
                <br />
                <strong>Fax:</strong>
                <%#DataBinder.Eval(Container.DataItem, "Fax")%>
                <br />
                <strong>City:</strong>
                <%#DataBinder.Eval(Container.DataItem, "City")%>
                <br />
                <strong>Country:</strong>
                <%#DataBinder.Eval(Container.DataItem, "Country")%>
            </div>
        </TilePeekTemplate>
    </DataBindings>
</telerik:RadTileList>
<telerik:RadButton ID="rbtnDeleteTiles" runat="server" Text="delete" OnClick="rbtnDeleteTiles_Click">
</telerik:RadButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [CustomerID], [ContactTitle], [ContactName], [Phone], [Fax], [City], [Country] FROM [Customers]  WHERE ContactTitle like 'Sales%'"></asp:SqlDataSource>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    PurchaseTileList.DataSourceID = "SqlDataSource1";
    PurchaseTileList.DataBind();
}
protected void rbtnDeleteTiles_Click(object sender, EventArgs e)
{
   string connstring = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    SqlConnection conn = new SqlConnection(connstring);
    conn.Open();
    foreach (RadBaseTile tile in PurchaseTileList.GetSelectedTiles())
    {
      string text=((RadImageAndTextTile)tile).Text;
      SqlCommand deleteQuery = new SqlCommand("DELETE FROM Customers WHERE CustomerID='" + text + "'",conn);
      deleteQuery.ExecuteNonQuery();
      conn.Close();
      PurchaseTileList.DataSourceID = "SqlDataSource1";
      PurchaseTileList.DataBind();
    }
}

Let me know if you have any concern.
Thanks,
Shinu.
Tags
TileList
Asked by
Tung
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or