or
this._displayElement.style.borderRightWidth=parseInt($telerik.getComputedStyle(this._displayElement,"borderRightWidth",""))+parseInt($telerik.getComputedStyle(this._textBoxElement,"borderRightWidth",""))+"px";<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <style type="text/css"> .wthrTitle { font-family: Tahoma; font-size: 14px; width: 370px; color: White; background: blue; border-top: 1px solid navy; text-align: center; } .wthrContainer { width: 74px; text-align: center; border: 1px; float: left; } .wthrDayTitle { font-family: Tahoma; font-size: 14px; width: 100%; color: White; background: blue; border-bottom: 1px solid navy; border-top: 1px solid navy; } .wthrForcast { font-family: Tahoma; font-size: 12px; color: blue; } .wthrTemp { font-family: Tahoma; font-size: 10px; color: blue; } .wthrClear { clear: left; } </style><div class="wthrTitle"><asp:Label ID="descriptionLabel" runat="server" Text='' /></div><telerik:RadListView ID="weatherRadListView" runat="server"> <ItemTemplate> <div class="wthrContainer"> <div class="wthrDayTitle"><asp:Label ID="dayLabel" runat="server" Text='<%# Eval("DayName") %>' /></div><br /> <asp:Image ID="forcastImage" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' /><br /> <asp:Label ID="forcastLabel" runat="server" Text='<%# Eval("Forcast") %>' CssClass="wthrForcast" /><br /> <div class="wthrForcast"><asp:Label ID="highLabel" runat="server" Text='<%# Eval("High") %>' />° - <asp:Label ID="lowLabel" runat="server" Text='<%# Eval("Low") %>' />°</div><br /> </div> </ItemTemplate></telerik:RadListView><br class="wthrClear" /><asp:HiddenField ID="zipcodeHidden" runat="server" Value="49333" />// By Phil Huhn 2012-01-08
using System;
using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;//using System.Xml;using System.Xml.Linq;using System.Net;//namespace Telerik.UserControls{ public partial class YahooWeather : System.Web.UI.UserControl { // // ------------------------------------------------------------------------ // Properties // ZipCode // #region "Properties" // /// <summary> /// External way to pass values to user control /// </summary> /// <value></value> /// <returns></returns> /// <remarks></remarks> public string ZipCode { get { return zipcodeHidden.Value; } set { zipcodeHidden.Value = value; } } // #endregion // /// <summary> /// call during each postback /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> protected void Page_Load(object sender, EventArgs e) { GetWeather(ZipCode); } // /// <summary> /// Get weather from yahoo /// </summary> /// <param name="zipCode"></param> /// <remarks></remarks> protected void GetWeather(string zipCode) { try { XDocument xmlData = XDocument.Load("http://xml.weather.yahoo.com/forecastrss/" + zipCode + "_f.xml"); // List<WeatherItem> _list = new List<WeatherItem>(); string _description = null; System.DateTime _date; //...<channel> foreach (XElement _row in xmlData.Root.Elements("channel")) { foreach (XElement _field in _row.Elements()) { //<title>Yahoo! Weather - Any Town</title> //<link></link> //<description>Yahoo! Weather for Any Town</description> if ((_field.Name.ToString() == "description")) { // cherry pick the desired data at this level. _description = _field.Value; descriptionLabel.Text = _description; } //<language>en-us</language> //<lastBuildDate>Sat, 07 Jan 2012 10:51 am EST</lastBuildDate> if ((_field.Name.ToString() == "lastBuildDate")) { string _dateString = _field.Value.Substring(5); _date = DateTime.Parse(_dateString.Substring(0, _dateString.Length - 4)); descriptionLabel.Text = _description + " at " + _date.ToShortTimeString(); } //<ttl>60</ttl> //<yweather:location city="Any Town" region="MI" country="US"/> //<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> //<yweather:wind chill="35" direction="310" speed="14"/> //<yweather:atmosphere humidity="65" visibility="10" pressure="29.89" rising="1"/> //<yweather:astronomy sunrise="8:02 am" sunset="5:17 pm"/> //<image> //<item> if (_field.Name.ToString() == "item") { foreach (XElement _itm in _field.Elements()) { if (_itm.Name.LocalName == "forecast") { WeatherItem _wi = new WeatherItem(); _wi.YahooForcast(_itm); _list.Add(_wi); } } } } } if (_list.Count > 0) { _list[0].DayName = "Today"; } weatherRadListView.DataSource = _list; weatherRadListView.DataBind(); } catch (Exception e) { int _i = 1; } } // }}public class WeatherItem{ public string DayName { get; set; } public System.DateTime Day { get; set; } public int Low { get; set; } public int High { get; set; } public string Forcast { get; set; } public string Code { get; set; } public string ImageUrl { get; set; } public string LocalImageUrl { get; set; } protected string LocalImagePath = "../Images/Weather/"; // public WeatherItem() { } // public WeatherItem(string localImagePath) { LocalImagePath = localImagePath; } // // <yweather:forecast day="Sun" date="8 Jan 2012" // low="28" high="37" text="Partly Cloudy" code="30"/> // public void YahooForcast(XElement forcastItem) { DayName = forcastItem.Attribute("day").Value; Day = Convert.ToDateTime(forcastItem.Attribute("date").Value); Low = Convert.ToInt32(forcastItem.Attribute("low").Value); High = Convert.ToInt32(forcastItem.Attribute("high").Value); Forcast = forcastItem.Attribute("text").Value; Code = forcastItem.Attribute("code").Value; ImageUrl = "http://l.yimg.com/a/i/us/we/52/" + Code + ".gif"; LocalImageUrl = LocalImagePath + Code + ".gif"; }}' By Phil Huhn 2012-01-08Option Strict OnOption Explicit On'Imports System.XmlImports System.Net'Public Class YahooWeather Inherits System.Web.UI.UserControl ' ' ------------------------------------------------------------------------ ' Properties ' ZipCode '#Region "Properties" ' ''' <summary> ''' External way to pass values to user control ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> Public Property ZipCode() As String Get Return zipcodeHidden.Value End Get Set(ByVal value As String) zipcodeHidden.Value = value End Set End Property ' #End Region ' ''' <summary> ''' call during each postback ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load GetWeather(ZipCode) End Sub ' ''' <summary> ''' Get weather from yahoo ''' </summary> ''' <param name="zipCode"></param> ''' <remarks></remarks> Protected Sub GetWeather(zipCode As String) Try Dim xmlData As Linq.XDocument = _ XDocument.Load("http://xml.weather.yahoo.com/forecastrss/" & zipCode & "_f.xml") ' Dim _list As New List(Of WeatherItem) Dim _description As String = Nothing Dim _date As Date = Nothing For Each _row As XElement In xmlData.Root.Elements("channel") '...<channel> For Each _field As XElement In _row.Elements '<title>Yahoo! Weather - Any Town</title> '<link></link> '<description>Yahoo! Weather for Any Town</description> If (_field.Name.ToString() = "description") Then ' cherry pick the desired data at this level. _description = _field.Value descriptionLabel.Text = _description End If '<language>en-us</language> '<lastBuildDate>Sat, 07 Jan 2012 10:51 am EST</lastBuildDate> If (_field.Name.ToString() = "lastBuildDate") Then Dim _dateString As String = _field.Value.Substring(5) _date = DateTime.Parse(_dateString.Substring(0, _dateString.Length - 4)) descriptionLabel.Text = _description & " at " & _date.ToShortTimeString End If '<ttl>60</ttl> '<yweather:location city="Any Town" region="MI" country="US"/> '<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> '<yweather:wind chill="35" direction="310" speed="14"/> '<yweather:atmosphere humidity="65" visibility="10" pressure="29.89" rising="1"/> '<yweather:astronomy sunrise="8:02 am" sunset="5:17 pm"/> '<image> '<item> If _field.Name.ToString() = "item" Then For Each _itm As XElement In _field.Elements If _itm.Name.LocalName = "forecast" Then Dim _wi As New WeatherItem() _wi.YahooForcast(_itm) _list.Add(_wi) End If Next End If Next Next If _list.Count > 0 Then _list(0).DayName = "Today" End If weatherRadListView.DataSource = _list weatherRadListView.DataBind() Catch e As Exception Dim _i As Integer = 1 End Try End Sub 'End ClassPublic Class WeatherItem Public Property DayName() As String Public Property Day() As Date Public Property Low() As Integer Public Property High() As Integer Public Property Forcast() As String Public Property Code() As String Public Property ImageUrl() As String Public Property LocalImageUrl() As String Protected LocalImagePath As String = "../Images/Weather/" ' Public Sub New() End Sub ' Public Sub New(localImagePath As String) localImagePath = localImagePath End Sub ' ' <yweather:forecast day="Sun" date="8 Jan 2012" ' low="28" high="37" text="Partly Cloudy" code="30"/> ' Public Sub YahooForcast(forcastItem As XElement) DayName = forcastItem.Attribute("day").Value Day = CDate(forcastItem.Attribute("date").Value) Low = CInt(forcastItem.Attribute("low").Value) High = CInt(forcastItem.Attribute("high").Value) Forcast = forcastItem.Attribute("text").Value Code = forcastItem.Attribute("code").Value ImageUrl = "http://l.yimg.com/a/i/us/we/52/" & Code & ".gif" LocalImageUrl = LocalImagePath & Code & ".gif" End SubEnd Class
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="RadControlsWebApp1.WebForm2" %><!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></title> <style type="text/css"> html, body, form { height: 100%; margin: 0px; padding: 0px; overflow: hidden; } </style></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js"> </asp:ScriptReference> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js"> </asp:ScriptReference> </Scripts> </telerik:RadScriptManager> <div id="ParentDivElement" style="height: 100%;"> <telerik:RadSplitter ID="MainSplitter" runat="server" Height="100%" Width="100%" Orientation="Horizontal" PanesBorderSize="0" BorderSize="0"> <telerik:RadPane ID="TopPane" runat="server" Height="88" Scrolling="none" CssClass="topPane" BorderStyle="None"> <h1>Top Menu Goes Here</h1> </telerik:RadPane> <telerik:RadSplitBar ID="HorizontalSplitterBar" runat="server" CollapseMode="None"></telerik:RadSplitBar> <telerik:RadPane ID="MainPane" runat="server" Scrolling="none" MinWidth="500"> <telerik:RadSplitter ID="NestedSplitter" runat="server" LiveResize="true" BorderStyle="None" CssClass="showTopBorder"> <telerik:RadPane ID="LeftPane" runat="server" Width="300"> <p>Side menu goes here</p> </telerik:RadPane> <telerik:RadSplitBar ID="VerticalSplitBar" runat="server" CollapseMode="None" /> <telerik:RadPane ID="ContentPane" runat="server" CssClass="valignPane"> <asp:Panel ID="Panel1" runat="server"> <div> This is a RadTextBox: <telerik:RadTextBox ID="RadTextBox1" runat="server"></telerik:RadTextBox> </div> <div style="height:1200px"> This div is here to force the pane to have a scroll bar. </div> </asp:Panel> </telerik:RadPane> </telerik:RadSplitter> </telerik:RadPane> </telerik:RadSplitter> </div> </form></body></html><asp:ImageButton ID="categoryImageBtn" OnClick="categoryBtn_Click" CommandName="Select" Height="30" Width="50" runat="server" ImageUrl='<%# Eval("ImagePath") %>' />
And in my codebehind I have this:
protected void myProjectListView_ItemCommand(object sender, RadListViewCommandEventArgs e)
{
if (e.CommandName == RadListView.SelectCommandName)
{
Label2.Text = "Bingo";
}
}
Just to see if it's working and needless to say... no luck :( I know the button works, as I wired up an onCLick event that fires fine.
I've tried various approaches in the tutorials with no luck.
I'd be very very grateful if someone could take a moment to point me in the right direction!
Paul
If e.DetailTableView.Name = "myModelGrid" Then sql = "Select intModelId, intMakeId, strModel from Drat_Model where intMakeId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intMakeId") & " AND bitArchive IS NULL ORder by strModel" e.DetailTableView.DataSource = getData(sql) End If<telerik:RadGrid ID="myRadGrid" runat="server" Width="100%" BorderWidth="1px" CellPadding="4" Skin="Web20"> <MasterTableView AutoGenerateColumns="false" DataKeyNames="intCategoryId" HierarchyDefaultExpanded="false" Font-Size="10" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center" Name="MasterGrid" ExpandCollapseColumn-ButtonType="ImageButton" HierarchyLoadMode="Client" AllowPaging="True" PageSize="20" PagerStyle-Mode="NumericPages" ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png"> <ItemStyle HorizontalAlign="Center" /><AlternatingItemStyle BackColor="#B0C4DE" HorizontalAlign="Center" /><HeaderStyle ForeColor="White" Font-Bold="true" /> <DetailTables> <telerik:GridTableView Name="myManufacGrid" runat="server" DataKeyNames="intManufacturerId" 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="intCategoryId" MasterKeyField="intCategoryId" /> </ParentTableRelation> <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="MostInnerHeaderStyle" /> <ItemStyle CssClass="MostInnerItemStyle" HorizontalAlign="Center" /> <AlternatingItemStyle CssClass="MostInnerAlernatingItemStyle" HorizontalAlign="Center" /> <DetailTables> <telerik:GridTableView DataKeyNames="intMakeID" Name="myMakeGrid" 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="intManufacturerId" MasterKeyField="intManufacturerId" /> </ParentTableRelation> <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="InnerSubHeaderStyle" /><ItemStyle CssClass="InnerSubItemStyle" HorizontalAlign="Center" /> <AlternatingItemStyle CssClass="InnerSubAlernatingItemStyle" HorizontalAlign="Center" /> <DetailTables> <telerik:GridTableView DataKeyNames="intModelId" Name="myModelGrid" 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="intMakeId" MasterKeyField="intMakeId" /> </ParentTableRelation> <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="InnerSubHeaderStyle" /><ItemStyle CssClass="InnerSubItemStyle" HorizontalAlign="Center" /> <AlternatingItemStyle CssClass="InnerSubAlernatingItemStyle" HorizontalAlign="Center" /> <Columns> <telerik:GridBoundColumn HeaderText="MODEL" DataField="strModel" /> <telerik:GridTemplateColumn HeaderText="Edit"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgModelEdit" CommandArgument='<%# bind("intModelId") %>' CommandName="ModelEdit" ImageUrl="~/Images/edit_icon.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Archive"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgModelArchive" CommandArgument='<%# bind("intModelId") %>' CommandName="ModelArchive" ImageUrl="~/Images/edit_icon.png" OnClientClick="return confirm('Are you sure you want to archive this Model, This will Archive everything Underneath as well.');" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </telerik:GridTableView> </DetailTables> <Columns> <telerik:GridBoundColumn HeaderText="MAKE" DataField="strmake" /> <telerik:GridTemplateColumn HeaderText="ADD MODEL"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgAddPosition" CommandArgument='<%# bind("intMakeID") %>' CommandName="AddModel" ImageUrl="~/Images/29.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Edit"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgMakeEdit" CommandArgument='<%# bind("intMakeID") %>' CommandName="MakeEdit" ImageUrl="~/Images/edit_icon.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Archive"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgMakeArchive" CommandArgument='<%# bind("intMakeID") %>' CommandName="MakeArchive" ImageUrl="~/Images/edit_icon.png" OnClientClick="return confirm('Are you sure you want to archive this Make, This will Archive everything Underneath as well.');" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </telerik:GridTableView> </DetailTables> <Columns> <telerik:GridBoundColumn HeaderText="MANUFACTURERS" DataField="strManufacturer"></telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="ADD MAKE"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgAddPosition" CommandArgument='<%# bind("intManufacturerId") %>' CommandName="AddMake" ImageUrl="~/Images/29.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Edit"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgManEdit" CommandArgument='<%# bind("intManufacturerId") %>' CommandName="ManEdit" ImageUrl="~/Images/edit_icon.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Archive"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgManArchive" CommandArgument='<%# bind("intManufacturerId") %>' CommandName="ManArchive" ImageUrl="~/Images/edit_icon.png" OnClientClick="return confirm('Are you sure you want to archive this Manufacturer, This will Archive everything Underneath as well.');" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </telerik:GridTableView> </DetailTables> <Columns> <telerik:GridBoundColumn HeaderText="Category" DataField="strCategory" /> <telerik:GridTemplateColumn HeaderText="Add Manufacturer"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgAdd" CommandArgument='<%# bind("intCategoryId") %>' CommandName="AddMan" ImageUrl="~/Images/29.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Edit"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgCatEdit" CommandArgument='<%# bind("intCategoryId") %>' CommandName="CatEdit" ImageUrl="~/Images/edit_icon.png" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderText="Archive"> <ItemTemplate> <asp:ImageButton runat="server" ID="imgCatArchive" CommandArgument='<%# bind("intCategoryId") %>' CommandName="CatArchive" ImageUrl="~/Images/edit_icon.png" OnClientClick="return confirm('Are you sure you want to archive this Category, This will Archive everything Underneath as well.');" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid>Protected Sub myRadGrid_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles myRadGrid.DetailTableDataBind If e.DetailTableView.Name = "myManufacGrid" Then sql = "Select intManufacturerId, intCategoryId, strManufacturer from Drat_Manufacturer where intcategoryId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intCategoryId") & " AND bitArchive IS NULL " _ & "Order by strManufacturer" e.DetailTableView.DataSource = getData(sql) End If If e.DetailTableView.Name = "myMakeGrid" Then sql = "Select intMakeID, intManufacturerID, strMake from Drat_Make where intManufacturerID = " & e.DetailTableView.ParentItem.GetDataKeyValue("intManufacturerId") & " AND bitArchive IS NULL ORder by strMake" e.DetailTableView.DataSource = getData(sql) End If If e.DetailTableView.Name = "myModelGrid" Then sql = "Select intModelId, intMakeId, strModel from Drat_Model where intMakeId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intMakeId") & " AND bitArchive IS NULL ORder by strModel" e.DetailTableView.DataSource = getData(sql) End If End SubProtected Sub myRadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadGrid.NeedDataSource Dim Cat As Integer = ddlCategory.SelectedValue Dim sqlWhere As String If Cat > 0 Then sqlWhere = "and intCategoryId = " & Cat & " Order by strCategory" Else sqlWhere = "Order by strCategory" End If sql = "Select intcategoryID, strCategory from Drat_Category where bitArchive IS NULL " & sqlWhere myRadGrid.DataSource = getData(sql) End Sub