problems with SELECT statement for updates

Discussion in 'ASP .Net Datagrid Control' started by paul.mcmanus.uk@googlemail.com, Apr 10, 2006.

  1. Guest

    Hi all,

    I'm using a datagrid to display and update information from several
    tables in SQL Server.

    I've created my SQL SELECT statement with the necessary INNER JOINs and
    this works correctly when displaying the data but for some reason when
    i edit one of the rows two copies of each row are displayed.

    my SELECT statement is as follows:

    SELECT imgSubjJUNCTid, imageID, kw_subject_lv1.subjectLv1_desc,
    kw_subject_lv2.subjectLv2_desc FROM junct_subject INNER JOIN
    kw_subject_lv1 ON junct_subject.subj_Lv1_ID =
    kw_subject_lv1.subjectLv1_ID INNER JOIN kw_subject_lv2 ON
    junct_subject.subj_Lv2_ID = kw_subject_lv2.subjectLv2_ID WHERE
    junct_subject.imageID = "+imgID

    my datagrid code is:

    <asp:DataGrid ID="dgSubjects" runat="server"
    AutoGenerateColumns="false" OnEditCommand="dg_edit"
    OnCancelCommand="dg_cancel" OnUpdateCommand="dg_update"
    ShowHeader="false">
    <Columns>

    <asp:TemplateColumn>
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "imgSubjJUNCTid") %>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox id="imgSubjJunct_ID" Text='<%#
    DataBinder.Eval(Container.DataItem, "imgSubjJUNCTid") %>'
    runat="server" />
    </EditItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn>
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "subjectLv1_desc") %>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:DropDownList ID="ddl_subject1" runat="server" DataSource='<%#
    getSubjectLv1() %>' DataTextField="subjectLv1_desc"
    DataValueField="subjectLv1_ID" OnSelectedIndexChanged='subjectFilter'
    />
    </EditItemTemplate>
    </asp:TemplateColumn>

    <asp:TemplateColumn>
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "subjectLv2_desc") %>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:DropDownList ID="ddl_subject2" runat="server" DataSource='<%#
    getSubjectLv2() %>' DataTextField="subjectLv2_desc"
    DataValueField="subjectLv2_ID" />
    </EditItemTemplate>
    </asp:TemplateColumn>

    <asp:EditCommandColumn EditText="Edit" UpdateText="OK"
    CancelText="Cancel"/>

    </Columns>
    </asp:DataGrid>



    does anyone have any experience of a similar problem,

    any ideas would be appreciated, thanks in advance

    Paul
     
    , Apr 10, 2006
    #1
    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. soulcode
    Replies:
    2
    Views:
    3,218
    soulcode
    May 6, 2004
  2. Michael
    Replies:
    9
    Views:
    335
    Richard Herring
    May 27, 2004
  3. Replies:
    7
    Views:
    341
  4. palmiere
    Replies:
    1
    Views:
    413
    Erwin Moller
    Feb 9, 2004
  5. Replies:
    16
    Views:
    168
    Richard Maher
    Mar 25, 2007
Loading...

Share This Page