data binding problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default data binding problem

    I have developped a custom user control (code at the end of the mail) which
    is an <input> tag with a customized source and onclick method.
    This custom control is in a repeater (in a template column of a datagrid, in
    fact), when the user clicked it and the web form is updated its Filename
    property has a now incorrect calue.

    however when I click on another input element (for example I click on the
    sort link at the top of the table) everything is then displayed correctly.

    I'm puzzled, any tip ?

    (Note: the Filename property is <%# databounded %>, of course !)

    //--------- WebPreviewer.cs -------
    using System;

    using System.Diagnostics;

    using System.Drawing;

    using System.Drawing.Imaging;

    using System.IO;

    using System.Text;

    using System.Web;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

    namespace perso

    {

    /// <summary>

    /// Summary description for WebCustomControl1.

    /// </summary>

    [DefaultProperty("Filename"),

    ToolboxData("<{0}:WebPreviewer runat=server></{0}:WebPreviewer>")]

    public class WebPreviewer : Control

    {

    private string text = @"?";

    [Bindable(true), Category("Appearance"), DefaultValue("")]

    public string Filename

    {

    get

    {

    return text;

    }

    set

    {

    text = value;

    }

    }

    int size;

    [Bindable(true), Category("Appearance"), DefaultValue("50")]

    public int Size

    {

    get

    {

    if(size < 1)

    return 50;

    return size;

    }

    set

    {

    size = value;

    }

    }

    protected override void OnPreRender(System.EventArgs e)

    {

    StringBuilder script = new StringBuilder();

    script.Append("<script language='javascript'><!--\n");

    script.Append("function __stuff_view(id,file,aW,aH){\n");

    script.Append("\targs =
    \"statuts,scrollbars,location,resizable,width=\"+a W+\",height=\"+aH;\n");

    script.Append("\topen(file, id, args);\n");

    script.Append("\treturn true;\n");

    //script.Append("\treturn false;\n");

    script.Append("}\n//--></script>");

    Page.RegisterClientScriptBlock("__stuff_view",scri pt.ToString());

    base.OnPreRender(e);

    }



    /// <summary>

    /// Render this control to the output parameter specified.

    /// </summary>

    /// <param name="output"> The HTML writer to write out to </param>

    protected override void Render(HtmlTextWriter output)

    {

    string myurl = Page.ResolveUrl(Filename);

    myurl = HttpUtility.UrlEncode(myurl);

    output.Write("<input type=image");

    output.Write(" src='Previewer.aspx?size=");

    output.Write(Size);

    output.Write("&url=");

    output.Write(myurl);

    output.Write('\'');

    output.Write(" onclick=\"return ");

    output.Write("__stuff_view('awin','");

    output.Write(myurl);

    output.Write("','500','500')");

    output.Write('\"');

    output.Write("/>\n");

    }

    }

    }


    Lloyd Dupont Guest

  2. Similar Questions and Discussions

    1. dynamic chart data binding problem
      Hello! I've been using Flex for all of about three days now, and have just hit a problem that I can't seem to find a solution for: I have a XML...
    2. Data Binding
      I have a webService, dataSet, comboBox and a sumbitButton. The combobox loads and displays Brands from my cfc. I press submit and look at the...
    3. Complex data binding question, binding child objects of a custom collection.
      I have a custom collection of objects, each of which includes a child object called MyUserOpener. In declarative binding, I can bind this property...
    4. problem in binding xml file data to datagrid xml file isgenerated through JSP file
      problem it that i am creating xml file using JSP file and i want to bind DataGrid with xml file data that is created using JSP but it will not Bind...
    5. Data Binding and Edit/Update/Cancel Chicken-and-Egg Problem
      Would you be able to help me out on this one? I've got a DataGrid control that I create dynamically - no problem there. I also add a hyperlink...
  3. #2

    Default Re: data binding problem

    my property Filename is set as follow
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "Name")>
    <asplloyd:WebPreviewer runat=server
    Filename='<%# DataBinder.Eval(Container.DataItem, "Name")>'/>
    </ItemTemplate>

    so I display the theoric value of filename which is correct.
    but for some reason the Filename property is not set ...


    "Lloyd Dupont" <lloyd@RemoveIfNotSpamming.galador.net> a écrit dans le
    message de news:un%23%23rsGTDHA.3192@tk2msftngp13.phx.gbl...
    > I have developped a custom user control (code at the end of the mail)
    which
    > is an <input> tag with a customized source and onclick method.
    > This custom control is in a repeater (in a template column of a datagrid,
    in
    > fact), when the user clicked it and the web form is updated its Filename
    > property has a now incorrect calue.
    >
    > however when I click on another input element (for example I click on the
    > sort link at the top of the table) everything is then displayed correctly.
    >
    > I'm puzzled, any tip ?
    >
    > (Note: the Filename property is <%# databounded %>, of course !)
    >
    > //--------- WebPreviewer.cs -------
    > using System;
    >
    > using System.Diagnostics;
    >
    > using System.Drawing;
    >
    > using System.Drawing.Imaging;
    >
    > using System.IO;
    >
    > using System.Text;
    >
    > using System.Web;
    >
    > using System.Web.UI;
    >
    > using System.Web.UI.WebControls;
    >
    > using System.ComponentModel;
    >
    > namespace perso
    >
    > {
    >
    > /// <summary>
    >
    > /// Summary description for WebCustomControl1.
    >
    > /// </summary>
    >
    > [DefaultProperty("Filename"),
    >
    > ToolboxData("<{0}:WebPreviewer runat=server></{0}:WebPreviewer>")]
    >
    > public class WebPreviewer : Control
    >
    > {
    >
    > private string text = @"?";
    >
    > [Bindable(true), Category("Appearance"), DefaultValue("")]
    >
    > public string Filename
    >
    > {
    >
    > get
    >
    > {
    >
    > return text;
    >
    > }
    >
    > set
    >
    > {
    >
    > text = value;
    >
    > }
    >
    > }
    >
    > int size;
    >
    > [Bindable(true), Category("Appearance"), DefaultValue("50")]
    >
    > public int Size
    >
    > {
    >
    > get
    >
    > {
    >
    > if(size < 1)
    >
    > return 50;
    >
    > return size;
    >
    > }
    >
    > set
    >
    > {
    >
    > size = value;
    >
    > }
    >
    > }
    >
    > protected override void OnPreRender(System.EventArgs e)
    >
    > {
    >
    > StringBuilder script = new StringBuilder();
    >
    > script.Append("<script language='javascript'><!--\n");
    >
    > script.Append("function __stuff_view(id,file,aW,aH){\n");
    >
    > script.Append("\targs =
    > \"statuts,scrollbars,location,resizable,width=\"+a W+\",height=\"+aH;\n");
    >
    > script.Append("\topen(file, id, args);\n");
    >
    > script.Append("\treturn true;\n");
    >
    > //script.Append("\treturn false;\n");
    >
    > script.Append("}\n//--></script>");
    >
    > Page.RegisterClientScriptBlock("__stuff_view",scri pt.ToString());
    >
    > base.OnPreRender(e);
    >
    > }
    >
    >
    >
    > /// <summary>
    >
    > /// Render this control to the output parameter specified.
    >
    > /// </summary>
    >
    > /// <param name="output"> The HTML writer to write out to </param>
    >
    > protected override void Render(HtmlTextWriter output)
    >
    > {
    >
    > string myurl = Page.ResolveUrl(Filename);
    >
    > myurl = HttpUtility.UrlEncode(myurl);
    >
    > output.Write("<input type=image");
    >
    > output.Write(" src='Previewer.aspx?size=");
    >
    > output.Write(Size);
    >
    > output.Write("&url=");
    >
    > output.Write(myurl);
    >
    > output.Write('\'');
    >
    > output.Write(" onclick=\"return ");
    >
    > output.Write("__stuff_view('awin','");
    >
    > output.Write(myurl);
    >
    > output.Write("','500','500')");
    >
    > output.Write('\"');
    >
    > output.Write("/>\n");
    >
    > }
    >
    > }
    >
    > }
    >
    >

    Lloyd Dupont Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139