我有一个组合框和一个值列表。
如果我添加一个值并将其保存,它应该出现在组合框中。但是它仅在刷新页面后出现。它不能正确绑定数据。
我已经把DataBind()
if (!Page.IsPostBack)
{
DataBind() ;
}
但是以上方法无济于事。
如何检查所有内容是否正确绑定。
请帮忙。
谢谢
protected void Page_Load(object sender, EventArgs e)
{
DataBind();
if (!Page.IsPostBack)
{
}
}
protected void btn_save_click(object sender, EventArgs e)
{
SqlCommand command_update = new SqlCommand("Update", connection_save1);
command_update.CommandType = System.Data.CommandType.StoredProcedure;
command_update.Parameters.Add(new SqlParameter("@ViewId", Int32.Parse(Id.Value)));
SqlParameter Returns = new SqlParameter("@ReturnCode", SqlDbType.Char);
Returns.Size = 1;
Returns.Direction = ParameterDirection.Output;
command_insert.Parameters.Add(Returns);
bSuccess = command_insert.Parameters["@ReturnCode"].Value.ToString();
if (bSuccess == "1")
{
//Response.Write("Insert successful");
dd_group.DataBind();
dd_group.SelectedValue = command_insert.Parameters["@ReturnCode"].Value.ToString().Trim();
}
}
这是HTML
<asp:DropDownList ID="dd_group" DataSourceID="sp" DataTextField="maintitle"
DataValueField="Id" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="group_SelectedIndexChanged1" Height="24px"
Width="50%">
</asp:DropDownList>
<asp:SqlDataSource ID="sp" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="GetIds" runat="server" SelectCommandType="StoredProcedure">
参考方案
protected void Pre_Render(object sender, EventArgs e)
{
DataBind();
}
protected void btn_save_click(object sender, EventArgs e)
{
SqlCommand command_update = new SqlCommand("Update", connection_save1);
command_update.CommandType = System.Data.CommandType.StoredProcedure;
command_update.Parameters.Add(new SqlParameter("@ViewId", Int32.Parse(Id.Value)));
SqlParameter Returns = new SqlParameter("@ReturnCode", SqlDbType.Char);
Returns.Size = 1;
Returns.Direction = ParameterDirection.Output;
command_insert.Parameters.Add(Returns);
bSuccess = command_insert.Parameters["@ReturnCode"].Value.ToString();
if (bSuccess == "1")
{
//Response.Write("Insert successful");
dd_group.DataBind();
dd_group.SelectedValue = command_insert.Parameters["@ReturnCode"].Value.ToString().Trim();
}
}
当回复有时是一个对象有时是一个数组时,如何在使用改造时解析JSON回复? - java我正在使用Retrofit来获取JSON答复。这是我实施的一部分-@GET("/api/report/list") Observable<Bills> listBill(@Query("employee_id") String employeeID); 而条例草案类是-public static class…
改造正在返回一个空的响应主体 - java我正在尝试使用Retrofit和Gson解析一些JSON。但是,我得到的响应机构是空的。当我尝试从对象中打印信息时,出现NullPointerException。我确保URL正确,并且我也确保POJO也正确。我正在使用jsonschema2pojo来帮助创建POJO类。这是我要解析的JSON{ "?xml": { "@versi…
ddl在服务器中未更新-asp.net - javascript我在ASP.NET c#上工作。我有一个DropDownList。 (runat =“ server”)在$ {document).ready上,我更新了它的值:$(document).ready(function () { document.getElementById("ddl").value = "abc"; ……
单击选项卡链接时,请专注于每个引导选项卡中的First asp:textbox - javascript我是开发的新手,并开始开发简单的asp.net应用程序。我正在使用每个都有一些asp标签和文本框的bootstrap选项卡。单击该选项卡时,我要重点关注选项卡内容中的第一个文本框。我搜索了各种答案,但都是针对输入字段的(exp:输入type =“ text”)。找不到适用于ASP文本框的任何内容。任何帮助将不胜感激。谢谢 javascript参考方案 ASP…
asp.net mvc中的对象数组数据始终为null - javascript我需要通过json将对象数组发送到asp.net mvc 2,但是我在mvc控制器中没有得到null对象是这样的entries[1].date = "12/22/2014" entries[1].Ref = "0002" entries[1].Credit = "100" entries[2].da…