私はコンボボックスとその中の値のリストを持っています。 値を追加して保存すると、コンボボックスに表示されます。しかし、私はページを更新した後にのみ表示されます。データを正しくバインドしません。Combobox Databind()check
私は
if (!Page.IsPostBack)
{
DataBind() ;
}
中に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();
}
}
あなたはコンボボックスに要素を追加するWebメソッドを使用することができ、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">
それは動作しません:( – Ish
は、C#のコードをアップロードしてください –
を私の編集を参照してください@Ish –