how did you bind the DataList, make sure it is inside
if (!IsPostBack)
{
//myList1.DataBind();
}
2:
<asp:datalist id="datalist_programe_url" style="Z-INDEX: 102; LEFT: 88px; POSITION: absolute; TOP: 536px"
runat="server" Height="136px">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox Runat="server" ID="editurlid" Text="edit"></asp:CheckBox>
<asp:Label Runat=server ID=url_id Text='<%# DataBinder.Eval(Container.DataItem, "my_p_id") %>' Visible=False>
</asp:Label>
<asp:ImageButton ImageUrl="pic/up.gif" Runat=server ID="order_up" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "my_c_order") %>' CausesValidation=False AlternateText=把播放顺序提前 OnCommand=set_play_order_up CommandName='<%# DataBinder.Eval(Container.DataItem, "my_p_id") %>'>
</asp:ImageButton>
<asp:ImageButton ImageUrl="pic/down.gif" Runat=server ID="order_down" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "my_c_order") %>' CausesValidation=False AlternateText=把播放顺序滞后 OnCommand=set_play_order_down CommandName='<%# DataBinder.Eval(Container.DataItem, "my_p_id") %>'>
</asp:ImageButton>
<asp:TextBox Text='<%# DataBinder.Eval(Container.DataItem,"my_c_name")%>' Runat=server ID='my_c_name' Width=150 οnchange="javascript:this.parentElement.parentElement.cells(0).children(0).checked=true;">
</asp:TextBox>
<asp:TextBox Text='<%# DataBinder.Eval(Container.DataItem,"my_url")%>' Runat=server ID='my_url' Width=280 οnchange="javascript:this.parentElement.parentElement.cells(0).children(0).checked=true;">
</asp:TextBox>
<asp:button ID="del" Text="删除" runat="server" CommandName="delete" oncommand="DataGrid_DeleteRow" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "my_p_id") %>' CausesValidation="false">
</asp:button>
</ItemTemplate>
<FooterTemplate>
<asp:Button id="Button4" runat="server" Text="提交修改节目名称或地址" CausesValidation="False" OnCommand="update_programe_name_url"></asp:Button>
</FooterTemplate>
</asp:datalist>
3:checkblog MycheckBlog=new checkblog();
MycheckBlog.OpenBase();
MycheckBlog.procedurename="update myprograme_info set my_c_name=@my_c_name,my_url=@my_url where my_p_id=@my_p_id and username=@username";
MycheckBlog.mysqlcommand=new SqlCommand(MycheckBlog.procedurename,MycheckBlog.myConnection);
MycheckBlog.mysqlcommand.Parameters.Add(new SqlParameter("@my_c_name", SqlDbType.NVarChar,50));
MycheckBlog.mysqlcommand.Parameters.Add(new SqlParameter("@my_url", SqlDbType.NVarChar,200));
MycheckBlog.mysqlcommand.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar,20));
MycheckBlog.mysqlcommand.Parameters.Add(new SqlParameter("@my_p_id", SqlDbType.Int));
foreach(DataListItem item in datalist_programe_url.Items)
{
CheckBox cb=(CheckBox)item.FindControl("editurlid");
if(cb.Checked)
{
Label lbl=(Label)item.FindControl("url_id");
TextBox my_c_name=(TextBox)item.FindControl("my_c_name");
TextBox my_url=(TextBox)item.FindControl("my_url");
MycheckBlog.mysqlcommand.Parameters["@my_c_name"].Value=my_c_name.Text;
MycheckBlog.mysqlcommand.Parameters["@my_url"].Value=my_url.Text;
MycheckBlog.mysqlcommand.Parameters["@username"].value="/str_name;
MycheckBlog.mysqlcommand.Parameters["@my_p_id"].Value=Convert.ToInt32(lbl.Text); "
MycheckBlog.mysqlcommand.ExecuteNonQuery();
}
}
MycheckBlog.CloseBase();
select_programe_url();