1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / button inside datalist

button inside datalist

26 posts, 0 answered
  1. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    15 Feb 2010
    Link to this post
    Hello everyone.

    I have a custom user control with two asp:panels in it.  The first is visible the second is not.

    The first panel is displayed by default and is working great.  The problem is that when a link, imagebutton, or just a plain button (I Don't Care Which at this point) is clicked inside of the datalist it is supposed to post back and hide the first panel and then display the second panel with all of the details for the selected item.

    None of theses options seems to fire a postback.  The page just refreshes.

    I know that this works if I add these same commands to a page but for some reason there is a conflict in the user control or in how Sitefinity is handling it.

    I have been working on this for hours and need some help.
  2. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    15 Feb 2010
    Link to this post
    I failed to mention that the first panel holds an asp:datalist with the button, link, image in question.
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Feb 2010
    Link to this post
    Hi bleutiger,

    Thank you for using our services.

    When you have buttons nested within the item template of a DataList, Repeater or GridView it is easier to use LinkButton and assign command names and command arguments to the link button. This way you will be able to bubble up the command and do what you need to do. Bellow is a sample user control containing two panels, a DataList with some items and acts exactly as you need it to.
    Markup:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Panels.ascx.cs" Inherits="Panels" %>
     
    <asp:Panel id="Output1" Visible="True" runat="server"
    style="width:200; height:200;  border:solid 1; padding:10">
      <asp:DataList ID="DataList1" runat="server" AlternatingItemStyle-BackColor="AliceBlue" ItemStyle-BackColor="LightBlue" Width="200" Height="100">
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server"/>
            <asp:LinkButton ID="Button1" Text="Show Details" runat="server"/>
        </ItemTemplate>
      </asp:DataList>
    </asp:Panel>
     
    <asp:Panel id="Output2" Visible="False" runat="server"
    style="width:200; height:200; background-color: #CC9999;
    color:#000000; border:solid 1; padding:10">
     
      <h3 style="text-align:center">asp:Panel</h3>
     
      <asp:Label ID="Label2" runat="server"/>
     
      <div style="text-align:center">
        <asp:LinkButton ID="Button2" Text="Show List" runat="server"/>
      </div>
     
    </asp:Panel>

    Code file:
    using System;
    using System.Collections.Generic;
    using System.Web.UI.WebControls;
    public partial class Panels : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //create items for the data list
            DataListItem item1 = new DataListItem(0, ListItemType.Item);
            item1.DataItem = "Data Item 1";
            DataListItem item2 = new DataListItem(1, ListItemType.AlternatingItem);
            item2.DataItem = "Data Item 2";
            List<DataListItem> itemsList = new List<DataListItem>();
            itemsList.Add(item1);
            itemsList.Add(item2);
            //subscribe to data list item data bound event
            DataList1.DataSource = itemsList;
            DataList1.ItemDataBound += new DataListItemEventHandler(DataList1_ItemDataBound);
            DataList1.DataBind();
     
            Button2.Click += new EventHandler(ShowPrevious);
        }
        void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                //set lite item data and subscribe to command execution
                Label Label1 = e.Item.FindControl("Label1") as Label;
                LinkButton Button1 = e.Item.FindControl("Button1") as LinkButton;
                if (Label1 != null && Button1 != null)
                {
                    DataListItem dataItem = (DataListItem)e.Item.DataItem;
                    Label1.Text = dataItem.DataItem as string;
                    Button1.CommandArgument = dataItem.DataItem as string;
                    Button1.CommandName = "Click";
                    Button1.Command += new CommandEventHandler(ShowNext);
                }
            }
        }
        //handle click command of data list item button click
        void ShowNext(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "Click")
            {
                Output1.Visible = false;
                Output2.Visible = true;
                Label2.Text = string.Concat((string)e.CommandArgument, " has link button been clicked");
            }
        }
        void ShowPrevious(object sender, EventArgs e)
        {
            Output2.Visible = false;
            Output1.Visible = true;
        }
    }

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    Radoslav,

    It is still not working and I don't know why.

    Your Code works fine but for some reason mine will not fire the post back.

    I am pasting all of my code so that you can help me figure out why it is not working.

    I made changes to my code based on the examples you sent be so I am really confused.

    you can see the page live at...  http://beta.lcisd.org/Schools/SchoolIndex.aspx

    My code will be in the next 2 posts.

  5. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    The Markup

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="SchoolList.ascx.cs" Inherits="CustomControls_SchoolList" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
      
    <p style="text-align:center;"><asp:LinkButton  ID="getSchools" runat="server" Text="All" onclick="getSchools_Click" />     |     <asp:LinkButton  ID="getElementarySchools" runat="server" Text="Elementary Schools" onclick="getSchools_Click" />     |     <asp:LinkButton  ID="getMiddleSchools" runat="server" Text="MiddleSchools" onclick="getSchools_Click" />     |     <asp:LinkButton  ID="getJRHighSchools" runat="server" Text="Junior High Schools" onclick="getSchools_Click" />     |     <asp:LinkButton  ID="getHighSchools" runat="server" Text="High Schools" onclick="getSchools_Click" /></p>
        <p> </p>
      
      
    <asp:Panel ID="ShowSchools" runat="server" Visible="true">
          
        <asp:DataList ID="SchoolList" runat="server" OnItemDataBound="SchoolList_ItemDataBound" >
            <ItemTemplate>
            <table cellpadding="0" cellspacing="0" style="width:726px; border:0px;" align="center">
        <tr>
            <td style="background-color:#CCC; padding-left:10px; font-weight:bold; font-size:15px; line-height:20px;" colspan="3"><asp:Label ID="lblSchoolLegalName" runat="server" Text="School Name" /></td>
        </tr>
        <tr>
            <td valign="top">
            <div style="width:235px; padding-left:10px;">
                <asp:Label ID="lblSchoolAddress" runat="server" Text="Address" />
                <br /><b>Phone: </b><asp:Label ID="lblSchoolPhone" runat="server" Text="" />
                <br /><b>Fax: </b><asp:Label ID="lblSchoolFax" runat="server" Text="" />
                <br /><asp:LinkButton ID="schMapButton" runat="server" ><asp:Image ImageUrl="~/Images/Icons/Map.gif" ID="mapIcon" runat="server" Width="35px" style="margin-right:12px;" />Map</asp:LinkButton>
                <br /><a href='<%# DataBinder.Eval(Container.DataItem, "SiteURL")  %>'><asp:Image ID="Image3" ImageUrl="~/Images/Icons/Url.png" alt="School Website" runat="server" BorderWidth="0px" Width="35px" style="vertical-align:middle;" /></a>   <a href='<%# DataBinder.Eval(Container.DataItem, "SiteURL")  %>'>School Website</a>
            </div>
              
            </td>
            <td valign="top">
            <div style="width:251px;">
            <b>Principal: </b><asp:Label ID="lblSchoolPrincipal" runat="server" Text="" /><br />
            <b>Current Enrollment: </b><asp:Label ID="lblSchEnrollment" runat="server" Text="0000" /><br>
            <a href='<%# DataBinder.Eval(Container.DataItem, "ReportCard")  %>' target="blank"><asp:Image ID="Image5" ImageUrl="~/Images/Icons/ReportCard.gif" alt="School Report Card" runat="server" BorderWidth="0px" Width="35px" style="vertical-align:middle;" /></a>   <a href='<%# DataBinder.Eval(Container.DataItem, "ReportCard")  %>' target="blank">School Accountability Report Card</a></div></td>
            <td valign="top">
            <div style="width:240px;">
                <div style="margin-right:10px;" align="right">
                    <asp:ImageButton ID="SchoolLogo2" runat="server" Width="200px" Height="200px" />
                      
                </div>
            </div>
            </td>
        </tr>
          
    </table>
            <p> </p>
            <p> </p>
            </ItemTemplate>
              
        </asp:DataList>
    </asp:Panel>
      
      
    <asp:Panel ID="showSingleSchool" runat="server" Visible="false">
        <asp:DataList ID="singleSchoolData" runat="server">
            <ItemTemplate>
            <table cellpadding="0" cellspacing="0" style="width:726px; border:0px;" align="center">
        <tr>
            <td style="background-color:#CCC; padding-left:10px; font-weight:bold; font-size:15px; line-height:20px;" colspan="3"><asp:Label ID="lblSchoolLegalName" runat="server" Text="School Name" /></td>
        </tr>
        <tr>
            <td valign="top">
              
              
            </td>
            <td valign="top">
            <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src='<%# DataBinder.Eval(Container.DataItem, "MapURL")  %>' style="margin:10px;"></iframe>
            </td>
            <td valign="top">
            <div style="width:280px; position:relative; float:right;">
                <div style="margin-right:10px; margin-left:10px;">
                    <asp:ImageButton ID="SchoolLogo1" runat="server" Width="200px" Height="200px" />
                      
                <br />
                  
                <asp:Label ID="lblSingleSchoolAddress" runat="server" Text="Address" />
                <br /><b>Phone: </b><asp:Label ID="lblSingleSchoolPhone" runat="server" Text="" />
                <br /><b>Fax: </b><asp:Label ID="lblSingleSchoolFax" runat="server" Text="" />
                  
              
            <br />
      
            <b>Principal: </b><asp:Label ID="lblSingleSchoolPrincipal" runat="server" Text="" /><br />
            <b>Current Enrollment: </b><asp:Label ID="lblSingleSchoolEnrollment" runat="server" Text="0000" /><br>
            <a href='<%# DataBinder.Eval(Container.DataItem, "ReportCard")  %>' target="blank"><asp:Image ID="Image5" ImageUrl="~/Images/Icons/ReportCard.gif" alt="School Report Card" runat="server" BorderWidth="0px" Width="35px" style="vertical-align:middle;" /></a>   <a href='<%# DataBinder.Eval(Container.DataItem, "ReportCard")  %>' target="blank">School Accountability Report Card</a>
            <br /><a href='<%# DataBinder.Eval(Container.DataItem, "SiteURL")  %>'><asp:Image ID="Image3" ImageUrl="~/Images/Icons/Url.png" alt="School Website" runat="server" BorderWidth="0px" Width="35px" style="vertical-align:middle;" /></a>   <a href='<%# DataBinder.Eval(Container.DataItem, "SiteURL")  %>'>School Website</a>
    </div>
              
            </div>
            </td>
        </tr>
          
    </table>
      
            </ItemTemplate>
        </asp:DataList>
          
        <div style="text-align:center">
        <asp:LinkButton ID="Button2" Text="Show List" runat="server" />
      </div>
    </asp:Panel>
  6. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    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 LCISD.Web.Business.SitefinityTools;
    using LCISD.Web.Data.SitefinityTools;
    using System.Data;
    using Telerik;
    using Telerik.Cms;
    using Telerik.Cms.Web;
    using Telerik.Web.UI;
    using Telerik.Caching;
      
      
    public partial class CustomControls_SchoolList : System.Web.UI.UserControl
    {
        string schoolType;
      
      
        protected void Page_Load(object sender, EventArgs e)
        {
            schoolType = "";
            createDataTable(schoolType);
      
      
            Button2.Click += new EventHandler(ShowList);
      
        }
      
        protected void createDataTable(string type)
        {
      
      
            DataTable schoolDT = new DataTable();
            LCISD.Web.Data.SitefinityTools.DataConn objSchools = new LCISD.Web.Data.SitefinityTools.DataConn();
            schoolDT = objSchools.GetSchoolList(type);
      
            SchoolList.DataSource = schoolDT;
            SchoolList.DataBind();
      
      
        }
      
        protected void SchoolList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SchoolList.DataKeyField = ((DataRowView)e.Item.DataItem).Row["SCHOOL_ID"].ToString();
      
                string schSchoolName = "";
                string schAddress = "";
      
                Label ctlSchoolName = (Label)e.Item.FindControl("lblSchoolLegalName");
                Label ctlSchoolAddress = (Label)e.Item.FindControl("lblSchoolAddress");
                Label ctlSchoolPhone = (Label)e.Item.FindControl("lblSchoolPhone");
                Label ctlSchoolFax = (Label)e.Item.FindControl("lblSchoolFax");
                Label ctlSchoolPrincipal = (Label)e.Item.FindControl("lblSchoolPrincipal");
                ImageButton ctlSchoolLogo = (ImageButton)e.Item.FindControl("SchoolLogo2");
                LinkButton ctlSchoolMap = (LinkButton)e.Item.FindControl("schMapButton");
                //Label ctlSchoolName = (Label)e.Item.FindControl("lblSchoolLegalName");
      
                schSchoolName = ((DataRowView)e.Item.DataItem).Row["SCHOOL_LEGAL_NAME"].ToString();
      
      
                schAddress = ((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE1"].ToString();
                if (((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE2"].ToString() != "")
                {
                    schAddress = schAddress + "<br />" + ((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE2"].ToString();
                }
      
                schAddress = schAddress + "<br />" + ((DataRowView)e.Item.DataItem).Row["CITY"].ToString() + ", " + ((DataRowView)e.Item.DataItem).Row["STATE_CODE"].ToString() + " " + ((DataRowView)e.Item.DataItem).Row["ZIP_CODE"].ToString();
      
                if (((DataRowView)e.Item.DataItem).Row["ZIP_CODE_EXT"].ToString() != "")
                {
                    schAddress = schAddress + "-" + "<br />" + ((DataRowView)e.Item.DataItem).Row["ZIP_CODE_EXT"].ToString();
                }
      
                ctlSchoolName.Text = schSchoolName;
                ctlSchoolAddress.Text = schAddress;
                ctlSchoolPhone.Text = ((DataRowView)e.Item.DataItem).Row["PHONE_NUMBER"].ToString();
                ctlSchoolFax.Text = ((DataRowView)e.Item.DataItem).Row["FAX_NUMBER"].ToString();
      
                ctlSchoolPrincipal.Text = ((DataRowView)e.Item.DataItem).Row["PRINCIPALNAME"].ToString();
      
                if (((DataRowView)e.Item.DataItem).Row["Logo"].ToString() == "")
                {
                    ctlSchoolLogo.Visible = false;
                }
                else
                {
                    ctlSchoolLogo.ImageUrl = "~/Images/SchoolLogoThumbs/" + ((DataRowView)e.Item.DataItem).Row["Logo"].ToString();
      
                    if (HttpContext.Current.Request.QueryString["cmspagemode"] == "edit")
                    {
                        // WE ARE IN EDIT MODE
                    }
                    else
                    {
      
                        ctlSchoolLogo.PostBackUrl = ((DataRowView)e.Item.DataItem).Row["SiteUrl"].ToString();
                    }
                }
      
      
                if (ctlSchoolMap != null)
                {
                    ctlSchoolMap.CommandArgument = ((DataRowView)e.Item.DataItem).Row["SCHOOL_ID"].ToString();
                    ctlSchoolMap.CommandName = "Click";
                    ctlSchoolMap.Command += new CommandEventHandler(ShowSingle);
                }
      
      
      
                ctlSchoolMap.CommandArgument = e.Item.ItemIndex.ToString();
      
            }
        }
      
      
        protected void getSchools_Click(object sender, EventArgs e)
        {
      
        }
      
      
      
        void ShowSingle(object source, CommandEventArgs e)
        {
      
            if (e.CommandName == "Click")
            {
      
                ShowSchools.Visible = false;
                showSingleSchool.Visible = true;
      
      
                string SchoolIDNum = e.CommandArgument.ToString();
      
                DataTable singleSchool = new DataTable();
                LCISD.Web.Data.SitefinityTools.DataConn objSchool = new LCISD.Web.Data.SitefinityTools.DataConn();
                singleSchool = objSchool.GetSingleSchool(SchoolIDNum);
      
                singleSchoolData.DataSource = singleSchool;
                singleSchoolData.DataBind();
            }
      
        }
      
        void ShowList(object sender, EventArgs e)
        {
            ShowSchools.Visible = true;
            showSingleSchool.Visible = false;
        }
      
      
        protected void singleSchoolData_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
      
      
                string schSchoolName = "";
                string schAddress = "";
      
                Label ctlSingleSchoolName = (Label)e.Item.FindControl("lblSchoolLegalName");
                Label ctlSingleSchoolAddress = (Label)e.Item.FindControl("lblSingleSchoolAddress");
                Label ctlSingleSchoolPhone = (Label)e.Item.FindControl("lblSingleSchoolPhone");
                Label ctlSingleSchoolFax = (Label)e.Item.FindControl("lblSingleSchoolFax");
                Label ctlSingleSchoolPrincipal = (Label)e.Item.FindControl("lblSingleSchoolPrincipal");
                ImageButton ctlSingleSchoolLogo = (ImageButton)e.Item.FindControl("SchoolLogo1");
                //ImageButton ctlSchoolMap = (ImageButton)e.Item.FindControl("schMapButton");
                //Label ctlSchoolName = (Label)e.Item.FindControl("lblSchoolLegalName");
      
                schSchoolName = ((DataRowView)e.Item.DataItem).Row["SCHOOL_LEGAL_NAME"].ToString();
      
      
                schAddress = ((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE1"].ToString();
                if (((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE2"].ToString() != "")
                {
                    schAddress = schAddress + "<br />" + ((DataRowView)e.Item.DataItem).Row["ADDRESS_LINE2"].ToString();
                }
      
                schAddress = schAddress + "<br />" + ((DataRowView)e.Item.DataItem).Row["CITY"].ToString() + ", " + ((DataRowView)e.Item.DataItem).Row["STATE_CODE"].ToString() + " " + ((DataRowView)e.Item.DataItem).Row["ZIP_CODE"].ToString();
      
                if (((DataRowView)e.Item.DataItem).Row["ZIP_CODE_EXT"].ToString() != "")
                {
                    schAddress = schAddress + "-" + "<br />" + ((DataRowView)e.Item.DataItem).Row["ZIP_CODE_EXT"].ToString();
                }
      
                ctlSingleSchoolName.Text = schSchoolName;
                ctlSingleSchoolAddress.Text = schAddress;
                ctlSingleSchoolPhone.Text = ((DataRowView)e.Item.DataItem).Row["PHONE_NUMBER"].ToString();
                ctlSingleSchoolFax.Text = ((DataRowView)e.Item.DataItem).Row["FAX_NUMBER"].ToString();
      
                ctlSingleSchoolPrincipal.Text = ((DataRowView)e.Item.DataItem).Row["PRINCIPALNAME"].ToString();
      
                if (((DataRowView)e.Item.DataItem).Row["Logo"].ToString() == "")
                {
                    ctlSingleSchoolLogo.Visible = false;
                }
                else
                {
                    ctlSingleSchoolLogo.ImageUrl = "~/Images/SchoolLogoThumbs/" + ((DataRowView)e.Item.DataItem).Row["Logo"].ToString();
                    //ctlSingleSchoolLogo.PostBackUrl = ((DataRowView)e.Item.DataItem).Row["SiteUrl"].ToString();
                    if (HttpContext.Current.Request.QueryString["cmspagemode"] == "edit")
                    {
                        // WE ARE IN EDIT MODE
                    }
                    else
                    {
      
                        ctlSingleSchoolLogo.PostBackUrl = ((DataRowView)e.Item.DataItem).Row["SiteUrl"].ToString();
                    }
                }
      
            }
        }
      
    }
  7. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    The map button is the one that should fire the postback and make the second panel appear.
  8. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Feb 2010
    Link to this post
    Hi Bleutiger,

    I noticed that the questions are related to general .net programming, rather to the product itself. We provided you with some working samples though. Unfortunately we are not possible to provide you with further customizations, because they fall beyond the realm of technical support. Hopefully some of the forum members may address them. You may also contact our partners for paid assistance. 

    Thank you for your understanding.

    Sincerely yours,
    Georgi
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    I disagree,

    I can get this code to work on a normal >net page and everything works fine.  It is only when I drop it into the Sitefinity environment that there is an issue so I would definately say it has to do with the product in some way.

    Something in Sitefinity is causing the postback not to fire correctly.
  10. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    ???
  11. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    16 Feb 2010
    Link to this post
    Hello Telerik Team.

    As I stated above this control does not work if you add it to a Sitefinity page and will not show the second panel and does not throw any type of error.

    I find it very dissapointing that no one has chosen to take a look at this.  If you wish I can send you a complete website project where this works for you to disect to your hearts content.

    As a license holder it was my understanding that we had unlimited tech support.  I chose to use the Forums as a venue for discussing this issue because others might be having a similar issue.

    Up until now I have been very happy with the responses here however This is not a simple .Net coding problem as was suggested. 
  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    The forums do not have guaranteed response time. Furthermore the standard response time on forums is 72 hours, where as with Support Tickets it is 48. Since our last post in this thread there have not been more than 24 hours passed. I think that us not responding for a bit more than 5 hours is not solid ground for disappointment (consider time between your last post and the one of Georgi). You should also take not that our business hours are 9:00 a.m. - 5 p.m. GMT +2. You can take a look at the following blog post on tips how to the best of Telerik Support.

    I want to reassure you that we are investigating all issues, both submitted though ticketing system and forums. Anyhow the problem should be coming from the fact that you are not properly subscribing to the ItemDataBound events of your data lists. In those data bound event handlers you have the code for setting up command name, argument and handler. This code is never reached. You can try subscribing to the event handler as in the sample I have provided:
    protected void Page_Load(object sender, EventArgs e)
    {
            schoolType = "";
            DataTable schoolDT = new DataTable();
            LCISD.Web.Data.SitefinityTools.DataConn objSchools = new LCISD.Web.Data.SitefinityTools.DataConn();
            schoolDT = objSchools.GetSchoolList(schoolType);
            SchoolList.DataSource = schoolDT;
            SchoolList.ItemDataBound+=new DataListItemEventHandler(SchoolList_ItemDataBound);
            SchoolList.DataBind();
            Button2.Click += new EventHandler(ShowList);
    }

    Then here too:
    void ShowSingle(object source, CommandEventArgs e)
    {
        if (e.CommandName == "Click")
        {
            ShowSchools.Visible = false;
            showSingleSchool.Visible = true;
            string SchoolIDNum = e.CommandArgument.ToString();
            DataTable singleSchool = new DataTable();
            LCISD.Web.Data.SitefinityTools.DataConn objSchool = new LCISD.Web.Data.SitefinityTools.DataConn();
            singleSchool = objSchool.GetSingleSchool(SchoolIDNum);
            singleSchoolData.ItemDataBound += new DataListItemEventHandler(singleSchoolData_ItemDataBound);
            singleSchoolData.DataSource = singleSchool;
            singleSchoolData.DataBind();
        }
    }


    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  13. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    I apologize for being a little short in my last post but I have been looking at this issue for 3 days and frustration got the better of me.

    Please explain something to me if you don't mind.

    I have never used these "subscribing to the ((Example:  singleSchoolData.ItemDataBound += new DataListItemEventHandler(singleSchoolData_ItemDataBound);)) "  commands before.  And in the sample I sent you with a regular.Net aspx page (not Sitefinity)  my code works just fine without it.

    Why do I need it in Sitefinity and how do I know when to use them and when they are not necessary?
  14. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    So in addition to my question above....I added the subscribe commands into the code as you directed and still no go.

    It never gets to the ShowSingle method in the code.

    What else should we try?
  15. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    You can try to either add AutoEventWireup="true" either to the master page which you are using or to the <pages> section in your web.config file:
    <pages autoEventWireup="true">
        <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        </controls>
    </pages>

    This will allow the automatic binding to the event handlers.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  16. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post

    The control already has that in the markup...

    <%

    @ Control Language="C#" AutoEventWireup="true" CodeFile="SchoolList.ascx.cs" Inherits="CustomControls_SchoolList" %>

    I will try it in the web.config will this cause any adverse effects elsewhere?

    And my question earlier about using the subscribe commands?

     

  17. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    Break point this if statement in the data bound event handler of the first DataList control:
    if (ctlSchoolMap != null)
    {
        ctlSchoolMap.CommandArgument = ((DataRowView)e.Item.DataItem).Row["SCHOOL_ID"].ToString();
        ctlSchoolMap.CommandName = "Click";
        ctlSchoolMap.Command += new CommandEventHandler(ShowSingle);
    }

     Then run the website in debug and see whether the code inside will be reached.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  18. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    Radoslav,

    When the page loads it hits the databind and the SchoolList.ItemDatabound and it hits the

    if (ctlSchoolMap != null)
    {
        ctlSchoolMap.CommandArgument = ((DataRowView)e.Item.DataItem).Row["SCHOOL_ID"].ToString();
        ctlSchoolMap.CommandName = "Click";
        ctlSchoolMap.Command += new CommandEventHandler(ShowSingle);
    }


    code (and yes it goes inside of the code) everytime.  I put the if not null in there as a precaution but the control exists on the page and it seems to be finding it.


    When I click on the linkbutton (ctlSchoolMap)  it hits the page load again and then cycles through the ItemDataBound method again hitting the ...

    if (ctlSchoolMap != null)
    {
        ctlSchoolMap.CommandArgument = ((DataRowView)e.Item.DataItem).Row["SCHOOL_ID"].ToString();
        ctlSchoolMap.CommandName = "Click";
        ctlSchoolMap.Command += new CommandEventHandler(ShowSingle);
    }


    piece of code everytime (and yes it goes inside of the code everytime).  However after that it just stops.  No errors no jumping to any other methods nothing.  The page refreshes and the first Datalist is displayed again.
  19. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    Check whether View State of the control is disabled, or the view state for the page where you have is disabled. This behavior sound like it can be coming from this. 

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  20. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    I have tried enabling teh viewstate for the Datalists but that seems to have no effect.

    How would I check on the viewstate for the whole control

    Or the viewstate of the page can be found in the admin dashboard for the page right?
  21. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    For pages select a page go to Properties tab for that page and expand the More Options section, there you have settings for the view state. When you click edit on a control in the page editor it generally has EnableViewState in Behavior section. Also check if View State is disabled globally from web.config.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  22. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    Viewstate for the page has NOT been disabled

    EnableViewState for the Control is Set to TRUE in the properties

    There are no references to Viewstate in the webconfig.
  23. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    Send us a project with database which has the tables you are accessing in the support ticket. Currently the control sent there is not runnable due to missing db tables.

    Regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  24. bleutiger
    bleutiger avatar
    153 posts
    Registered:
    23 Oct 2008
    17 Feb 2010
    Link to this post
    How do you want be to send it as I can only upload pics here?

    Do you want me to submit a new support ticket?
  25. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    17 Feb 2010
    Link to this post
    Hello bleutiger,

    The the support ticket with the same issue you have previously opened.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  26. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Feb 2010
    Link to this post
    Hi bleutiger,

    The issue was with the setting of PostBackUrl property of the image button: 
    if (HttpContext.Current.Request.QueryString["cmspagemode"] == "edit")
    {
        // WE ARE IN EDIT MODE
    }
    else
    {
        ctlSchoolLogo.PostBackUrl = ((DataRowView)e.Item.DataItem).Row["SiteUrl"].ToString();
    }

    As an alternative solution you can bind to the ctlSchoolLogo click command and pass as an argument the SiteUrl. Then upon execution of the click command perform a response redirect or server transfer to the url taken from command argument.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
26 posts, 0 answered