Gridview ASP.NET c# data from the same table

Asked

Viewed 987 times

2

I have the following table in SQL with the following fields (id, name, day week, active). id the primary key of the whole type; nvchar day nvchar week; active bit; and I have the following data in the table 1 ;Jose ;Monday;1; 2; Jose; Quartafeira; 1; i want to show this data on a gridview of type;

Tipo colunas: TEXTBOX || Checkbox || Checkbox|| Checkbox||...
Nome colunas:  nome || segunda || terça || quarta ||...
Dados:        jose  || x       ||        || x ||...

when editing removes the record from that day, and if it does not exist it creates a new record for the respective day. I’m doing this on web Forms Aplication. I hope Dé to understand what I want.

  • 1

    Try to skip line, try to be more specific, read your question calmly and try to do it in a way that facilitates understanding and is as complete as possible (detailed)

2 answers

2

Is it possible? Of course it is. But if you really want to get help with your case, you need to provide more specific details as @tchicotti suggested.

With what is possible to understand with your question, it is only possible to say yes, and that in the display you need to fill in the "checkboxes" according to the data returned by your query, and, according to the action of the user you will need to either update a record or enter a new record.

2


        <%@ Page Language="C#" AutoEventWireup="false" CodeFile="Template.aspx.cs" Inherits="Template" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Explorando o GridView - Visual C#</title>
</head>
<body>
    <form id="form1" runat="server">
        <br />
        <table width="60%" align="center" bgcolor="#cccccc" cellpadding="1" cellspacing="0">            
            <tr>
                <td>
                    <table width="100%" align="center" bgcolor="#ffffff">
                        <tr>
                            <td align="center">
                                <br />
                                <font face="arial" size="2">
                                    <b>Explorando o GridView - Visual C#</b><br />
                                    Por Felipe Albuquerque<br />
                                    <a href="mailto:[email protected]">[email protected]</a><br />
                                    <a href="felipealbuquerq.blogspot.com" target="_blank">http://http://felipealbuquerq.blogspot.com</a>
                                </font>
                            </td>
                        </tr>
                        <tr><td><br /><hr size="1" noshade /><br /></td></tr>
                        <tr>
                            <td>
                                <font face="arial" size="2">
                                    <table width="100%" align="center">
                                        <tr>
                                            <td><b>Utilizando Template Columns</b></td>
                                            <td align="right"><a href="Default.aspx"><< Indice</a></td>
                                        </tr>
                                        <tr><td colspan="2">&nbsp;</td></tr>
                                        <tr>
                                            <td colspan="2">
                                                <br />
                                                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnString %>"
                                                    SelectCommand="SELECT [*] FROM [Agenda]"></asp:SqlDataSource>
                                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
                                                    <Columns>
                                                        <asp:BoundField DataField="Nome" HeaderText="Nome" SortExpression="Nome" />
                                                        <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="SegundaFeira" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                                                        <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="TercaFeira" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                                                        <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="QuartaFeira" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                                                        <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="QuintaFeira" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                                                        <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="SextaFeira" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                                                    </Columns>
                                                </asp:GridView>
                                            </td>
                                        </tr>
                                    </table>
                                </font>
                            </td>
                        </tr>
                        <tr><td><hr size="1" noshade /></td></tr>
                        <tr><td align="right"><a href="http://beta.asp.net"><img border="0" src="Images/ASPNET.gif" /></a>&nbsp;</td></tr>
                    </table>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.