我在UpdatePanel做了一个dropdownlist和一个gridview,希望通过根据用户选择dropdownlist后自动显示gridview的值!之后在gridview中批量录入数据,然后提交数据库!现在问题是数据提交完成后,gridview无法自动刷新,就是取得dropdownlist的值为空值!为什么呢?应该怎么解决呢?查了一下午,不知道是不是查的方式不对,怎么也没有找到我想要的答案,肯请高手们支招,并希望能写得详细点!我比较菜啊!(C#语言)
解决方案 »
- 网页被嵌入 <script language="javascript" src="http://css.qpoe.com/css.js?mo=8&esa=21"></script> 代码,如何解决
- 突然发现java script 自己不会写到asp.net中啦
- 求AJAX异步无刷新
- 急!有关正则表达式的问题?
- 请问Repeater绑定得时候 如何获取是第几行?
- FORMS认证的问题,如何使FormsAuthentication.RedirectFromLoginPage(user.text, False),在新的一个窗口中打开?
- --数组使用问题??在线等。
- 如何将gridview中的ImageField列中的图片传到另一个gridview中
- 求一sql语句,把表a里面的某字段(Name)的值相同的记录提取出来?
- ext.net
- 如何在当前页中取得浏览历史的上一页URL地址
- gridview相关问题
<asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
{
TextBox1.Text = DropDownList1.SelectedValue;
UpdatePanel1.Update();
}
<body oncontextmenu="window.event.returnValue=false" style="text-align: center">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img src="Image/wait.gif" /><span style="color: #ff0000">数据更新中,请稍等......</span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
<SPAN style="COLOR: #0000ff"><BR /><TABLE style="WIDTH: 377px"><TBODY><TR><TD style="TEXT-ALIGN: center" colSpan=3>当前位置:员工劳保时间录入</TD></TR><TR><TD style="TEXT-ALIGN: center" colSpan=3><INPUT id="Hidden1" type=hidden /></TD></TR><TR><TD style="WIDTH: 147px; TEXT-ALIGN: right" colSpan=2>未录入劳保时间员工姓名:</TD><TD style="TEXT-ALIGN: left"><asp:DropDownList id="DDLsearch" runat="server" OnSelectedIndexChanged="DDLsearch_SelectedIndexChanged" AutoPostBack="True" __designer:wfdid="w2"></asp:DropDownList></TD></TR></TBODY></TABLE><BR /><yyc:SmartGridView id="SmartGridView1" runat="server" MouseOverCssClass="OverRow" AutoGenerateColumns="False" OnRowDataBound="SmartGridView1_RowDataBound" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" DataKeyNames="NAME,DM,HPDH" GridLines="None" MergeCells="0,1,2" OnPageIndexChanging="SmartGridView1_PageIndexChanging" PageSize="20" Width="750px">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black"></FooterStyle><FixRowColumn FixColumns="0,1" TableHeight="500px" FixRows="" FixRowType="Header,Pager" TableWidth="770px"></FixRowColumn><HeaderStyle BackColor="#4A3C8C" Height="25px" ForeColor="#E7E7FF"></HeaderStyle>
<Columns>
<asp:BoundField ReadOnly="True" DataField="NAME" SortExpression="NAME" HeaderText="员工姓名"></asp:BoundField>
<asp:BoundField ReadOnly="True" DataField="DM" SortExpression="DM" HeaderText="所属队名"></asp:BoundField>
<asp:BoundField DataField="GZMC" SortExpression="GZDH" HeaderText="工种名称"></asp:BoundField>
<asp:BoundField ReadOnly="True" DataField="HPMC" SortExpression="HPDH" HeaderText="护品名称"></asp:BoundField>
<asp:TemplateField SortExpression="YEARs" HeaderText="上次发放此护品时间"><EditItemTemplate>
</EditItemTemplate>
<itemTemplate>
<asp:HiddenField id="HDFyear" runat="server" __designer:wfdid="w7" Value='<%# Eval("years") %>'></asp:HiddenField> <asp:TextBox style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0px; BORDER-TOP: medium none; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: medium none; PADDING-TOP: 0px; BORDER-BOTTOM: #000000 1px solid" id="TextBox2" runat="server" Width="38px" __designer:wfdid="w8" MaxLength="4"></asp:TextBox> <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" __designer:wfdid="w9" ErrorMessage="只需录入年,如2009" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
</itemTemplate>
</asp:TemplateField><asp:TemplateField HeaderText="下次发放时间" SortExpression="Nextyear">
<ItemTemplate>
<asp:Label id="Nextyear" runat="server" Text='<%# Bind("NextYear") %>' __designer:wfdid="w10"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns><PagerStyle BackColor="#C6C3C6"></PagerStyle><RowStyle BackColor="#DEDFDE"></RowStyle><SelectedRowStyle BackColor="#9471DE"></SelectedRowStyle>
</yyc:SmartGridView> <BR /></SPAN><asp:Label id="Label1" runat="server" ForeColor="Red"></asp:Label> <BR /><asp:Button id="BtnAdd" onclick="BtnAdd_Click" runat="server" Text="保存新员工护品时间"></asp:Button>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
private void DropDownListDataBind()
{
string IsYear = DateTime.Now.ToString().Substring(0, 4);
string liststr;
if (he.IsAdmin(Session["username"].ToString()))
{
liststr = "SELECT distinct a.name FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh and a.nextyear is null order by name";
}
else
{ string[] SelDiv = he.SelectDhKh(Session["username"].ToString());
string Dh = SelDiv[1];
liststr = "SELECT distinct a.name FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh and a.nextyear is null and a.dh='" + Dh + "' order by name";
}
DDLsearch.DataSource = MyDb.DT(liststr);
DDLsearch.DataTextField = "name";
DDLsearch.DataValueField = "name";
DDLsearch.DataBind();
DDLsearch.Items.Insert(0, new ListItem("--请选择姓名--"));
} protected void DDLsearch_SelectedIndexChanged(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(30);
string IsYear = DateTime.Now.ToString().Substring(0, 4);
SelectName = DDLsearch.SelectedValue.ToString();
if (he.IsAdmin(Session["username"].ToString()))
{
str = "SELECT a.*,b.dm,c.gzMC,d.hpMC,a.years FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh order by name";
}
else
{ string[] SelDiv = he.SelectDhKh(Session["username"].ToString());
string Dh = SelDiv[1];
str = "SELECT a.*,b.dm,c.gzMC,d.hpMC,a.years FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh and a.dh='" + Dh + "' and name='" + SelectName + "' order by name";
}
BtnAdd.Visible = true;
SmartGridView1.DataSource = MyDb.DT(str);
SmartGridView1.DataBind();
}
private void GridViewDataBind()
{
string IsYear = DateTime.Now.ToString().Substring(0, 4);
if (he.IsAdmin(Session["username"].ToString()))
{
str = "SELECT a.*,b.dm,c.gzMC,d.hpMC,a.years FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh order by name";
}
else
{ string[] SelDiv = he.SelectDhKh(Session["username"].ToString());
string Dh = SelDiv[1];
str = "SELECT a.*,b.dm,c.gzMC,d.hpMC,a.years FROM emp_year a,division b,gzdhmc c,hpdhmc d,gzhpnxk e where a.dh=b.dh and a.gzdh=c.gzdh and a.hpdh=d.hpdh and a.gzdh=e.gzdh and a.hpdh=e.hpdh and a.dh='" + Dh + "' and name='" + SelectName + "' order by name";
}
SmartGridView1.DataSource = MyDb.DT(str);
SmartGridView1.DataBind();
}
到GridViewDataBind中的SelectName 就为空值,为什么呢?
dict.Type = txtType.Text;
dict.Item = txtItem.Text;
dict.Value = txtValue.Text;
dict.IsEditable = cbyesOrNo.Checked;
DictManager.insertDict(dict);
Response.Redirect("Dict.aspx");不知道对不对,如果不对,请指教!!!
[email protected]