可编辑datagrid
程序员文章站
2022-06-07 19:41:29
...
<asp:datagrid id="dgrdS" runat="server" Width="470px" ShowHeader="false" CellPadding="0" AutoGenerateColumns="False">
<HeaderStyle Font-Size="9pt" HorizontalAlign="Center" Height="20px" BackColor="Silver"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="課題">
<ItemStyle CssClass="dgidlabs"></ItemStyle>
<ItemTemplate>
<asp:label ID="lblweekss" width="99px" Text='<%# DataBinder.Eval(Container.DataItem, "Weeks")%>' Runat="server" Visible=False/>
<asp:label ID="lblprojCDs" width="99px" Text='<%# DataBinder.Eval(Container.DataItem, "PJID")%>' Runat="server" Visible=False/>
<asp:label ID="lblprojs" width="148px" Text='<%# DataBinder.Eval(Container.DataItem, "PJName")%>' Runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="課題">
<ItemStyle CssClass="dgidlabs"></ItemStyle>
<ItemTemplate>
<asp:label ID="lblprocCDs" width="99px" Text='<%# DataBinder.Eval(Container.DataItem, "AdvanceCD")%>' Runat="server" Visible=False/>
<asp:label ID="lblprocs" width="148px" Text='<%# DataBinder.Eval(Container.DataItem, "PJAdvanceName")%>' Runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="課題">
<ItemStyle CssClass="dgidlabs"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lalproblems" Runat=server Width="148px" Text='<%# DataBinder.Eval(Container.DataItem, "ProblemName")%>'>
</asp:Label>
<asp:Label ID="lalproblemCDs" Runat=server Width="99px" Text='<%# DataBinder.Eval(Container.DataItem, "ProblemCD")%>' Visible=False>
</asp:Label>
<asp:dropdownlist id="DropdownlistS" Runat="server" Width="148px" Visible="False" ></asp:dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="課題">
<ItemStyle CssClass="dgidlabs"></ItemStyle>
<ItemTemplate>
<asp:textbox Width="148px" TextMode="MultiLine" Height="100%" ID="Solvers" Text='<%# DataBinder.Eval(Container.DataItem, "Solver")%>' Runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="課題">
<ItemStyle CssClass="dgidlabs"></ItemStyle>
<ItemTemplate>
<asp:textbox Width="148px" TextMode="MultiLine" Height="100%" ID="Comments" Text='<%# DataBinder.Eval(Container.DataItem, "Comment")%>' Runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
foreach(DataGridItem i in this.dgrdS.Items) { DropDownList DropDownLists=(DropDownList)i.FindControl("DropDownLists"); Label lblweekss=(Label)i.FindControl("lblweekss"); Label lblprojCDs=(Label)i.FindControl("lblprojCDs"); Label lblprocCDs=(Label)i.FindControl("lblprocCDs"); TextBox Solvers=(TextBox)i.FindControl("Solvers"); TextBox Comments=(TextBox)i.FindControl("Comments"); if(Comments.Text.Trim().Length<=0||Solvers.Text.Trim().Length<=0) { Page.RegisterStartupScript("", "<script>alert('Nullがありますから、入力してください。。')</script>"); } if(Solvers.Text.Length>20) { Page.RegisterStartupScript("", "<script>alert('対応者中20文字以内で入力してください。。')</script>"); } if(Comments.Text.Length>200) { Page.RegisterStartupScript("", "<script>alert('備考中200文字以内で入力してください。。')</script>"); } SqlParameter[] para = new SqlParameter[6]; para[0] = new SqlParameter("@weeks",SqlDbType.Int); para[0].Value =lblweekss.Text; para[1] = new SqlParameter("@pjCD",SqlDbType.VarChar); para[1].Value =lblprojCDs.Text; para[2] = new SqlParameter("@advanceCD",SqlDbType.Int); para[2].Value =lblprocCDs.Text; para[3] = new SqlParameter("@problemCD",SqlDbType.SmallInt); para[3].Value =DropDownLists.SelectedItem.Value; para[4] = new SqlParameter("@solverName",SqlDbType.NVarChar); para[4].Value =Solvers.Text; para[5] = new SqlParameter("@commentName",SqlDbType.NVarChar); para[5].Value =Comments.Text; SqlHelper.ExecuteNonQuery(SqlHelper.dsn,CommandType.StoredProcedure,"dbo.M_All_Write",para); //this.dgKaisowuList.DataSource=this.CreateDataSource //((BoundColumn)this.dgKaisowuList.Columns[9]).DataField=strHinSyuCD; }
上一篇: 7-7 两个有序序列的中位数
下一篇: 运用日期升序来排序,而且日期必须大于0