Binding data to a server control inside repeator control

Discussion in 'ASP .Net' started by muthu, Apr 6, 2006.

  1. muthu

    muthu Guest

    Hi guys,

    Iam using a repeator control in my page.In wich i have
    dropdown list as the last column.I have a label in the first
    column.Now i have binded a datable to the repeator in the page load
    event.And assigned vale to the label in html as

    <asp:Label ID="c_invAmt" Runat="server" cssclass="smcsAmountLabel">
    <%# DataBinder.Eval(Container.DataItem,"InvoiceAmount") %>
    </asp:Label>


    Now i want to bind data to the dropdown list in the last column.I have
    a function that returns a datatable.

    I tried to bind the dropdown in html as follows

    <asp:DropDownList ID="c_currencyList" Runat="server" Visible="False"
    DataSource='<%=GetCurrencies()%>' DataTextField="XXX"
    DataValueField="XXX">
    </asp:DropDownList>

    But it throws an error saying

    The datasource property is set only by the run time.It cannot be
    declared.

    So i tried to bind the dropdown list in the itemdatabound event of the
    repeator.But the data is not binded to the dropdown list.

    How can i achieve that.Can any one help me out...........
     
    muthu, Apr 6, 2006
    #1
    1. Advertising

  2. So bind it at runtime

    "muthu" wrote:

    > Hi guys,
    >
    > Iam using a repeator control in my page.In wich i have
    > dropdown list as the last column.I have a label in the first
    > column.Now i have binded a datable to the repeator in the page load
    > event.And assigned vale to the label in html as
    >
    > <asp:Label ID="c_invAmt" Runat="server" cssclass="smcsAmountLabel">
    > <%# DataBinder.Eval(Container.DataItem,"InvoiceAmount") %>
    > </asp:Label>
    >
    >
    > Now i want to bind data to the dropdown list in the last column.I have
    > a function that returns a datatable.
    >
    > I tried to bind the dropdown in html as follows
    >
    > <asp:DropDownList ID="c_currencyList" Runat="server" Visible="False"
    > DataSource='<%=GetCurrencies()%>' DataTextField="XXX"
    > DataValueField="XXX">
    > </asp:DropDownList>
    >
    > But it throws an error saying
    >
    > The datasource property is set only by the run time.It cannot be
    > declared.
    >
    > So i tried to bind the dropdown list in the itemdatabound event of the
    > repeator.But the data is not binded to the dropdown list.
    >
    > How can i achieve that.Can any one help me out...........
    >
    >
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 6, 2006
    #2
    1. Advertising

  3. muthu

    muthu Guest

    What do you mean to say.....
     
    muthu, Apr 6, 2006
    #3
  4. The error says you can't bind the data like you are doing, i.e.
    declaratively, you can only do it at runtime. So do it at runtime instead.

    E.G. Don't do this:

    DataSource='<%=GetCurrencies()%>'

    Put something like this in you pageload event

    if (!IsPostBack)
    {
    c_currencyList.DataSource = SomeDataSourceObject;
    c_currencyList.DataBind();
    }

    "muthu" wrote:

    > What do you mean to say.....
    >
    >
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 6, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pat Sagaser via .NET 247
    Replies:
    0
    Views:
    2,529
    Pat Sagaser via .NET 247
    May 13, 2004
  2. Steve Lloyd
    Replies:
    2
    Views:
    391
    Steve Lloyd
    May 19, 2004
  3. muthu

    Doubt in repeator control

    muthu, Apr 5, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    350
    Eliyahu Goldin
    Apr 5, 2006
  4. muthu
    Replies:
    0
    Views:
    331
    muthu
    Apr 6, 2006
  5. cs_in_va

    Display Images with Repeator

    cs_in_va, Mar 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    292
    sloan
    Mar 5, 2008
Loading...

Share This Page