C#关于gridview增删改查,并且实现下拉菜单的绑定

zt1120110894 2015-04-29 02:29:58
想做一个这样的页面


自己在VS2010中设计如下

其中工序名,机床,刀具,夹具需要下拉菜单dropdownlist从SQL server数据表中选择。

其他各项为textbox

最后增加的数据也能保存在SQL server 数据库表中、


<asp:GridView ID="GridView2" runat="server" Width="90%" CellPadding="4" ForeColor="#333333"
AutoGenerateColumns="False" AllowPaging="True" PageSize="12" OnRowCancelingEdit="GridView2_RowCancelingEdit"
OnRowEditing="GridView2_RowEditing" OnRowDeleting="GridView2_RowDeleting"
DataKeyNames="ProcessesName" OnPageIndexChanging="GridView2_PageIndexChanging"
DataMember="ProcessesName" OnRowDataBound="GridView2_RowDataBound"
GridLines="None" Height="36px" >
<Columns>
<asp:TemplateField HeaderText="工序号">
<ItemTemplate>
<asp:TextBox ID="TextBoxGXH" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="工序名">

<EditItemTemplate>
<asp:HiddenField ID="ProcessesNameHD" runat="server" Value='<%# Eval("ProcessesName") %>' />
<asp:DropDownList ID="DDLProcessesName" runat="server" Width="90px" />
</EditItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>


<asp:TemplateField HeaderText="工序描述"><ItemTemplate>
<asp:TextBox ID="TextBoxGXMS" runat="server"></asp:TextBox>
</ItemTemplate></asp:TemplateField>


<asp:TemplateField HeaderText="机床代号"></asp:TemplateField>
<asp:TemplateField HeaderText="刀具代号"></asp:TemplateField>
<asp:TemplateField HeaderText="夹具代号"></asp:TemplateField>


<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" HeaderText="操作"
ShowInsertButton="True" />
</Columns>



请问SQL中表格怎么建立还有就是后面的事件代码怎么写?

...全文
409 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
z22708387 2015-05-12
  • 打赏
  • 举报
回复
select name,ProcesseingMethod from FeatureModel where 精度上限='xxx' and 精度下限='xxx' and Ra上限='xxx' and Ra下限='xxx' 精度上限、精度下限、Ra上限、Ra上限代表你在表中所代表的字段. 'xxx' 代表你界面上所选择的值.
zt1120110894 2015-05-12
  • 打赏
  • 举报
回复
错了,将FeatureModel表格中的name和ProcesseingMethod两个字段查出来,放在新表Table中
zt1120110894 2015-05-12
  • 打赏
  • 举报
回复
问一个关于SQLserver问题

有一张表,名字FeatureModel,字段如下

在vs2010中界面设计如下‘

代码:

<td>
<br /> <br /> <br /> <br />
    <asp:Label ID="Label1" runat="server"
Text="特征名称:"></asp:Label>
    

<asp:TextBox ID="TextBox1" runat="server" Height="16px" Width="132px"></asp:TextBox>
<br />
<br />     <asp:Label ID="Label2" runat="server"
Text="精度上限:"></asp:Label>
    
<asp:DropDownList ID="DropDownList1" runat="server" Height="17px" Width="134px">
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
<br />
<br />    <asp:Label ID="Label3" runat="server" Text="精度下限:"></asp:Label>
    
<asp:DropDownList ID="DropDownList2" runat="server" Height="17px" Width="134px">
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
<br />
<br />     <asp:Label ID="Label5" runat="server"
Text="Ra上限:"></asp:Label>
      
<asp:DropDownList ID="DropDownList3" runat="server" Height="17px" Width="134px">
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>12.5</asp:ListItem>
<asp:ListItem>6.3</asp:ListItem>
<asp:ListItem>1.6</asp:ListItem>
<asp:ListItem>0.4</asp:ListItem>
<asp:ListItem>0.1</asp:ListItem>
</asp:DropDownList>
<br />
<br />    <asp:Label ID="Label6" runat="server"
Text="Ra下限:"></asp:Label>
      
<asp:DropDownList ID="DropDownList4" runat="server" Height="17px" Width="134px">
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>6.3</asp:ListItem>
<asp:ListItem>1.6</asp:ListItem>
<asp:ListItem>0.2</asp:ListItem>
<asp:ListItem>0.1</asp:ListItem>
<asp:ListItem>0.012</asp:ListItem>
</asp:DropDownList>
<br />
<br />           
<br />
 <asp:Button
ID="Button2" runat="server" Text="确定" />                
    

<asp:Button ID="Button1" runat="server" Text="返回"
PostBackUrl="~/Manufacturing Method/newfound.aspx"
/>


</td>


想实现的功能,是在下拉菜单里面选择“精度上限、精度下限、Ra上限、Ra下限”然后从FeatureModel中选择这些值相同的项,把相同的查询出来,填入新的表。Table,该如何实现?
z22708387 2015-04-29
  • 打赏
  • 举报
回复
-.-设计不明确. 新建、编辑可以在另一个页面完成。 GridView用来展示就好。列表里可以留【编辑】、【删除】功能。 1、如果单条新建,没有必要做在GridView中,既增加了负荷,也县的不美观,操作起来麻烦,并且你画面设计也不完整。 2、从性能方面考虑,【新建】、【编辑】都可以创建一个新的aspx页面来完成,通过Url传值来判断是做【新建】还是【编辑】 3、单独操作一个功能,对于你写Sql也方便。 如果没有特定的需求,没有必要将界面设计成这样。 望楼主考虑清楚。
静静-风 2015-04-29
  • 打赏
  • 举报
回复
 <asp:Button ID="Button1" runat="server" CommandName="Delete" CommandArgument='<%#Eval("id") %>'  Text="删除" />
        <asp:Button ID="Button2" runat="server" CommandName="Update"  Text="修改" />
        <asp:Button ID="Button3" runat="server" CommandName="Insert"  Text="添加" />
ItemCommand switch (e.CommandName) { case "Delete": break ..... } 是这意思吗?

110,549

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧