解决方案 »
- 下载功能
- 求 asp.net mvc2.0框架 导出EXCEL 例子?
- js错误,大侠帮忙
- C# 字符串中的数字后面加/
- 一個加密鎖dll本地vs調試沒有問題iis發佈后提示尝试读取或写入受保护的记忆体。这通常表示其他记忆体已损毁
- |zyciis| 如何在UserList:UserBase;UserBase中如何反射得到UserList的属性,谢谢
- 传值问题没说清楚,在散 40分!!!!
- .net 中可以编写在ie中使用的ActiveX吗?编完后又如何加入到asp.net 页面中,在客户端自动使用呢?
- 自定义的类中如何灵活使用response.write方法!
- 请问怎样编译单个CS文件
- excel数据导入问题
- 请教大神帮我解决下微信JSSDk接口签名错误的问题?在线等
欢迎追问!
//GridView设置
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None"
BorderWidth="1px" CellPadding="3" CellSpacing="2" DataKeyNames="产品编号"
ShowFooter="True" Width="642px"
OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView1_RowDataBound"
onpageindexchanging="GridView1_PageIndexChanging" PageSize="5"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
style="font-size: small">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<Columns>
<asp:TemplateField HeaderText="产品名称">
<ItemTemplate>
<%#HightLightText((string)Eval("产品"), this.tbSearch.Text.Trim())%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="单价" HeaderText="单价" SortExpression="单价"
ReadOnly="True" />
<asp:BoundField DataField="库存量" HeaderText="库存量" SortExpression="库存量"
ReadOnly="True" />
<asp:BoundField DataField="已订购量" HeaderText="已订购量" SortExpression="已订购量"
ReadOnly="True" />
<asp:TemplateField HeaderText="订货金额" SortExpression="订货金额">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("订货金额", "{0:c}") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="OrderTotalLabel" runat="server" Font-Underline="True" ForeColor="Red"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("订货金额", "{0:c}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="是否停售">
<EditItemTemplate>
<asp:DropDownList ID="ddlSellState" runat="server" AutoPostBack="True">
<asp:ListItem Value="True">停售</asp:ListItem>
<asp:ListItem Value="False">不停售</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("SellState") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="设置" ShowEditButton="True" />
</Columns>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#C0FFC0" Font-Bold="True" ForeColor="Black" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
//cs页面关联下拉框绑定问题
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int ID=int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
bool PaperState = bool.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlSellState")).SelectedValue);
string strsql = "UPDATE tb_OrderForm SET 是否停售 = @SellState WHERE 产品编号= @ID";
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
SqlCommand comm = new SqlCommand(strsql, conn);
comm.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int, 4));
comm.Parameters["@ID"].Value = ID;
comm.Parameters.Add(new SqlParameter("@SellState", SqlDbType.Bit, 1));
comm.Parameters["@SellState"].Value = PaperState;
if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0)
{
Response.Write("<script language=javascript>alert('设置成功!');location='Default.aspx'</script>");
}
else
{
Response.Write("<script language=javascript>alert('设置失败!');location='Default.aspx'</script>");
}
//取消编辑操作
GridView1.EditIndex = -1;
//调用自定义方法DbBind()重新绑定GridView控件中信息
DbBind();
}