私はすでにGridView
完全に動作するように設定されていますが、今はいくつかを設定する必要がありparameters
ます。に入力gridview
していHTML page
ます。巨大なコードなので、FULL GridView HTML code
スパムと見なさないでください。
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" style="font-family: Verdana, Arial, Sans-Serif"
DataKeyNames="id"
CssClass="gridview" DataSourceID="MyDataSource"
AllowSorting ="True" AllowPaging="True" BackColor="#CCCCCC"
BorderStyle="Inset" BorderWidth="2px" BorderColor="GrayText"
CellPadding="1"
CellSpacing="5"
HeaderStyle-HorizontalAlign="Center"
OnRowDataBound="GridView1_RowDataBound"
ForeColor = "Black" RowStyle-CssClass="gridview"
onrowcommand="GridView1_RowCommand">
<AlternatingRowStyle BackColor="#CCCCCC" />
<columns>
<asp:BoundField HeaderText="ID" DataField="id" />
<asp:BoundField HeaderText="PRIORIDADE" DataField="prioridade" SortExpression="prioridade" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="SITUAÇÃO" DataField="situacao" SortExpression="situacao" ItemStyle-HorizontalAlign="Center" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="RESPONSAVEL" DataField="responsavel" SortExpression="responsavel" HeaderStyle-Width="65px" ItemStyle-HorizontalAlign="Center">
<HeaderStyle Width="65px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="DATA DE CADASTRO" DataField="dt_cadastro" DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="60px"
SortExpression="dt_cadastro" ItemStyle-HorizontalAlign="Center" >
<HeaderStyle Width="60px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="PREVISÃO DE TÉRMINO" DataField="previsao_termino" DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="60px"
SortExpression="previsao_termino" ItemStyle-HorizontalAlign="Center">
<HeaderStyle Width="60px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField HeaderText="PROJETO" DataField="projeto" ItemStyle-HorizontalAlign="Center"></asp:BoundField>
<asp:BoundField HeaderText="FUNCIONALIDADE" DataField="funcionalidade" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField HeaderText="CLUBE" DataField="clube" SortExpression="clube" ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderStyle-Width="70px" HeaderText="VISUALIZAR" >
<ItemTemplate>
<asp:Button ID="Btn_Visualizar" runat="server" Text="VISUALIZAR" CssClass="Btn_Grid" Font-Size="7pt" Font-Names="Verdana, Arial"
CommandName="visualizar" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderStyle-Width="66px" HeaderText="ALTERAR">
<ItemTemplate>
<asp:Button ID="Btn_Alterar" runat="server" Text="ALTERAR" CssClass="Btn_Grid" Font-Size="7pt" Font-Names="Verdana, Arial"
CommandName="editar" CommandArgument="<%# ((GridViewRow)Container).RowIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</columns>
<EditRowStyle ForeColor="Black" CssClass="GridViewEditRow" />
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" BorderColor="White" BorderStyle="Solid" BorderWidth="1px" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="MyDataSource" runat="server"
ConnectionString="server=localhost;User Id=xx;password=xxxx;database=xxxx"
ProviderName ="MySql.Data.MySqlClient"
SelectCommand="SELECT ch.id, sit.descricao as situacao, resp.responsavel, ch.dt_cadastro, ch.previsao_termino, func.descricao as funcionalidade,
proj.descricao as projeto ,pr.id as prid, pr.prioridade, clb.clube
FROM chamados AS ch
INNER JOIN prioridades as pr ON ch.prioridade = pr.id
INNER JOIN clubes as clb ON ch.clube = clb.id
INNER JOIN responsaveis as resp ON ch.responsavel = resp.id
INNER JOIN situacoes as sit ON ch.situacao = sit.id
INNER JOIN projetos as proj ON ch.projeto = proj.id
INNER JOIN funcionalidades as func ON ch.funcionalidade = func.id WHERE situacao != 3"
UpdateCommand="Update chamados SET status = @status , responsavel = @responsavel,
previsao_termino = @previsao_termino, titulo = @titulo WHERE id = @id"
DeleteCommand="Delete FROM chamados WHERE id = @id">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="status" Type="String" />
<asp:Parameter Name="responsavel" Type="String" />
<asp:Parameter Name="previsao_termino" Type="DateTime" />
<asp:Parameter Name="titulo" Type="String" />
<asp:Parameter Name="id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
このすべてをファイルで行うにはどうすればよいですかAspx.cs
、DataSet を作成し、DataSource として GridView に設定し、値を列に設定するにはどうすればよいですか? ありがとう !Obs: 私もセルに 2 つのボタンを持っています。parameter
[コメント] - 他の解決策は、以下のコードでa を渡すことですが、可能ですか? の値を渡す必要がありますSession