ItemTemplate Problem

Discussion in 'ASP .Net Datagrid Control' started by CarlS, Jul 7, 2012.

  1. CarlS

    CarlS

    Joined:
    Jul 6, 2012
    Messages:
    1
    Likes Received:
    0
    I have a simple datagrid that is bound to a filtered dataset. The filter attributes can be selected from a number of dropdown lists on the form, and the form posted back.

    The problem I have is that a bound textbox control in the datagrid does not update when the form is posted, whereas all the other bound columns do.


    <asp:TemplateColumn ItemStyle-Wrap="False" HeaderText="Match Date" ItemStyle-HorizontalAlign="Center">
    <itemtemplate>
    <asp:Textbox CssClass="fixdate" Width="100" Runat="server" ID="txtMatchDate" Text='<%# Container.DataItem("MatchDate")%>' ></asp:Textbox>
    </itemtemplate>
    </asp:TemplateColumn>

    <asp:BoundColumn ReadOnly="True" DataField="MatchDate" HeaderText="Match Date" SortExpression="MatchDate"></asp:BoundColumn>

    The two columns show above both bind to the MatchDate field. The BoundColumn shows show the corrrectly bound data at every postback, whereas the textbox in the TemplateColumn always shows the data from the first time time it is bound.
     
    CarlS, Jul 7, 2012
    #1
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.