Click here to Skip to main content
15,913,055 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to add new row dynamic into dataset Pin
indiaone6-Sep-07 20:50
indiaone6-Sep-07 20:50 
AnswerRe: How to add new row dynamic into dataset Pin
VenkataRamana.Gali6-Sep-07 21:04
VenkataRamana.Gali6-Sep-07 21:04 
GeneralRe: How to add new row dynamic into dataset Pin
indiaone6-Sep-07 21:21
indiaone6-Sep-07 21:21 
Questionforms authentication Pin
saiprasada6-Sep-07 20:50
saiprasada6-Sep-07 20:50 
AnswerRe: forms authentication Pin
VenkataRamana.Gali6-Sep-07 21:06
VenkataRamana.Gali6-Sep-07 21:06 
GeneralRe: forms authentication Pin
saiprasada6-Sep-07 21:23
saiprasada6-Sep-07 21:23 
QuestionObject moved error - Urgent Pin
NK76-Sep-07 20:41
NK76-Sep-07 20:41 
QuestionClass inherting User Control and implementing ITemplate Pin
tsramkumar6-Sep-07 20:40
tsramkumar6-Sep-07 20:40 
Hi I have created a user control which inherits from UserControl amd implements ITemplate. I am setting my datalist's item template to this external resource using Page.LoadControl. But when the datalist is bound to a datasource, I don't see the data displayed in the expected way. Only the last item in the datasource is displayed by the datalist for the item template colum.
Here is my class.

UserControl code behind
========================
<br />
   public partial class StateListTemplate : System.Web.UI.UserControl, System.Web.UI.ITemplate<br />
    {<br />
        private bool _bDisplayStateName = false;<br />
<br />
        public bool DisplayStateName<br />
        {<br />
            set {_bDisplayStateName = value;}<br />
            get { return _bDisplayStateName;}<br />
        }<br />
<br />
        public void InstantiateIn(System.Web.UI.Control container)<br />
        {<br />
            container.Controls.Add(this);<br />
        }<br />
        ....<br />
        protected string GetStateDisplayString(string sStateCode, string sStateName)<br />
        {<br />
            if (DisplayStateName)<br />
                return new           System.Text.StringBuilder(sStateCode.Trim()).Append("-").Append(sStateName.Trim()).ToString();<br />
            else<br />
                return sStateCode;<br />
        }<br />
<br />


User Control .ascx
==================
<br />
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StateListTemplate.ascx.cs" Inherits="EtaxWeb.UserControls.StateListTemplate" %><br />
<asp:Label runat="server" Text="Test1"></asp:Label><br />
<%# GetStateDisplayString((string)DataBinder.Eval(((DataListItem)Container).DataItem, "Value"), (string)DataBinder.Eval(((DataListItem)Container).DataItem, "Text"))%><br />


Code where the datalist's itemtemplate is set to the above user control and datbound.
<br />
            StateListTemplate stlist = (StateListTemplate)LoadControl("../UserControls/StateListTemplate.ascx");<br />
            stlist.DisplayStateName = false;<br />
            dlStates.ItemTemplate = stlist;<br />
            dlStates.DataSource = states;<br />
            dlStates.DataBind();<br />


I could have just used a class with ITemplate interface, but just wanted to see if this is possible as it would help to code the controls declaritively in the user control and add it to the container in the InstantiateIn method rather than having to declare eacha nd every control and adding it to the container.

Any Help is appreciated!
QuestionCheckbox and FileUpload control query Pin
Shaurya_Rastogi6-Sep-07 20:39
Shaurya_Rastogi6-Sep-07 20:39 
QuestionHow to handle Multiple Asynchronous Requests at one time? Pin
IshfaqHussain6-Sep-07 20:04
IshfaqHussain6-Sep-07 20:04 
QuestionCascadingDropDown and AutoCompleteExtender Pin
varshavmane6-Sep-07 19:05
varshavmane6-Sep-07 19:05 
AnswerRe: CascadingDropDown and AutoCompleteExtender Pin
Imran Khan Pathan6-Sep-07 19:44
Imran Khan Pathan6-Sep-07 19:44 
GeneralRe: CascadingDropDown and AutoCompleteExtender Pin
varshavmane6-Sep-07 19:57
varshavmane6-Sep-07 19:57 
GeneralRe: CascadingDropDown and AutoCompleteExtender Pin
Imran Khan Pathan6-Sep-07 20:25
Imran Khan Pathan6-Sep-07 20:25 
GeneralRe: CascadingDropDown and AutoCompleteExtender Pin
varshavmane6-Sep-07 20:39
varshavmane6-Sep-07 20:39 
QuestionError including master page in general forms Pin
Dhyanga6-Sep-07 18:50
Dhyanga6-Sep-07 18:50 
QuestionLogin Controls from toolbox Pin
duo!@#6-Sep-07 18:28
duo!@#6-Sep-07 18:28 
AnswerRe: Login Controls from toolbox Pin
Sandeep Akhare6-Sep-07 19:43
Sandeep Akhare6-Sep-07 19:43 
GeneralRe: Login Controls from toolbox Pin
duo!@#6-Sep-07 20:29
duo!@#6-Sep-07 20:29 
AnswerRe: Login Controls from toolbox Pin
satyaki mishra6-Sep-07 23:18
satyaki mishra6-Sep-07 23:18 
QuestionAccess Denied Pin
Rmesh6-Sep-07 17:42
Rmesh6-Sep-07 17:42 
AnswerRe: Access Denied Pin
Imran Khan Pathan6-Sep-07 18:06
Imran Khan Pathan6-Sep-07 18:06 
GeneralRe: Access Denied Pin
Rmesh6-Sep-07 23:17
Rmesh6-Sep-07 23:17 
AnswerRe: Access Denied Pin
Sandeep Akhare6-Sep-07 19:47
Sandeep Akhare6-Sep-07 19:47 
GeneralRe: Access Denied Pin
Rmesh6-Sep-07 23:31
Rmesh6-Sep-07 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.