asp:gridView - write cells to labels on update
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: asp:gridView - write cells to labels on update

  1. #1
    Join Date
    Aug 2011
    Posts
    2

    asp:gridView - write cells to labels on update

    Hi! I have an asp:gridview. On top of it is a form, the user types in something and it gets written to the grid. A user can also edit some other cells in the grid table by clicking on edit in the left column. It works fine. But when the edit is done I want some cells to be written to labels.

    First, what event do I use? OnRowUpdating? OnRowCommand? OnRowUpdated? I have tried alot. One time I only got the cell with the primary key written out but not any other cell. Now when Iam using the OnRowCommand I get the cells that the user filled in with the form written out but not the edited cells.

    Here is the front end code (some swedish text in there, yes)

    <div id="grid">
    <asp:GridView ID="Grid" runat="server" RowStyle-CssClass="rowA" AlternatingRowStyle-CssClass="rowB"
    AutoGenerateColumns="false" DataKeyNames="ID"
    DataSourceID="SqlDataSource1" AutoGenerateEditButton="true"
    OnRowUpdating="Grid_RowUpdating" OnRowCommand="Grid_RowCommand">
    <Columns>
    <asp:BoundField ReadOnly="true" DataField="ID" HeaderText="ID" InsertVisible="False" SortExpression="ID" />
    <asp:BoundField ReadOnly="true" DataField="Beskrivning" HeaderText="Beskrivning" SortExpression="Beskrivning" />
    <asp:BoundField ReadOnly="true" DataField="Prioritet" HeaderText="Prioritet" SortExpression="Prioritet" />
    <asp:BoundField ReadOnly="true" DataField="Namn" HeaderText="Namn" SortExpression="Namn" />
    <asp:BoundField ReadOnly="true" DataField="Epost" HeaderText="Epost" SortExpression="Epost" />
    <asp:BoundField ReadOnly="true" DataField="Datum" HeaderText="Datum" SortExpression="Datum" />
    <asp:BoundField ReadOnly="true" DataField="Tid" HeaderText="Tid" SortExpression="Tid" />
    <asp:BoundField DataField="Svar" HeaderText="Svar" SortExpression="Svar" />
    <asp:BoundField DataField="Svarsnamn" HeaderText="Svarsnamn" SortExpression="Svarsnamn" />
    <asp:BoundField DataField="Svarsepost" HeaderText="Svarsepost" SortExpression="Svarsepost" />
    <asp:BoundField ReadOnly="true" DataField="Svarsdatum" HeaderText="Svarsdatum" SortExpression="Svarsdatum" />
    <asp:BoundField ReadOnly="true" DataField="Svarstid" HeaderText="Svarstid" SortExpression="Svarstid" />
    </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT * FROM [issuesTable] ORDER BY [Svar], [Svarsdatum], [Svarstid]"
    UpdateCommand="UPDATE [issuesTable] SET Svar=@Svar,Svarsnamn=@Svarsnamn,Svarsepost=@Svarsepost,Svarsdatum=@Svarsdatum,Svarstid=@Svarstid where ID = @ID">
    <UpdateParameters>
    <asp:Parameter Name="Svar" Type="String" />
    <asp:Parameter Name="Svarsnamn" Type="String" />
    <asp:Parameter Name="Svarsepost" Type="String" />
    <asp:Parameter Name="Svarsdatum" Type="String" />
    <asp:Parameter Name="Svarstid" Type="String" />
    </UpdateParameters>
    </asp:SqlDataSource>
    </div>
    <asp:Label runat="server" ID="mailToName"></asp:Label>
    <asp:Label runat="server" ID="mailToAdress"></asp:Label>
    <asp:Label runat="server" ID="mailToMessageBeskrivning"></asp:Label>
    <asp:Label runat="server" ID="mailFromName"></asp:Label>
    <asp:Label runat="server" ID="mailFromAdress"></asp:Label>
    <asp:Label runat="server" ID="mailToMessageSvar"></asp:Label>


    I need help badly. Thanks alot

  2. #2
    Join Date
    Aug 2011
    Posts
    2

    Re: asp:gridView - write cells to labels on update

    I solved it. Thanks anyway.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center