国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET中RadioButtonList綁定后臺數據后觸發點擊事件

2024-07-10 12:47:14
字體:
來源:轉載
供稿:網友

本文實例為大家分享了RadioButtonList綁定后臺數據,觸發點擊事件的方法

首先前臺頁面放置一個RadioButtonList 控件

<asp:RadioButtonList runat="server" ID="RadioButtonList1" BorderStyle="None" RepeatColumns="3" CssClass=""      RepeatLayout="Flow" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">    </asp:RadioButtonList>

.cs文件 后臺綁定數據

namespace BTApp{ public partial class Technology : System.Web.UI.Page {  string Id;  protected void Page_Load(object sender, EventArgs e)  {   if (!IsPostBack)   {    AspNetPager1.PageSize = 10;    if (Request.QueryString["Id"] != null)    {     Id = Request.QueryString["Id"];    }    else    { Id = ""; }    GetDataBind(Id);    DropDownListDataBind();   }  }  //RadioButtonList綁定后臺數據  private void DropDownListDataBind()  {   ExpertInfoBLL bll = new ExpertInfoBLL();   DataTable dt = bll.GetDepInfo();   foreach (DataRow dr in dt.Rows)   {    RadioButtonList1.Items.Add(dr["Name"].ToString());//循環讀出數據庫的數據       }   this.RadioButtonList1.DataSource = dt;   this.RadioButtonList1.DataTextField = "Name";   this.RadioButtonList1.DataValueField = "Id";   this.RadioButtonList1.RepeatDirection = RepeatDirection.Horizontal;   this.RadioButtonList1.DataBind();    }  private void GetDataBind(string Id)  {   //這里寫解碼和數據庫返回結果   TechnologyBLL bll = new TechnologyBLL();   string strWhere = " 1=1 ";   if (Id != "" && Id != null)   {    strWhere += string.Format(" and a.Depinfo_Id = '{0}'", Id);   }   AspNetPager1.RecordCount = bll.GetCountList(strWhere);   //綁定數據    DataTable dt = bll.GetList((AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize, AspNetPager1.PageSize, strWhere, "CreateTime");   this.Repeater1.DataSource = dt;   this.Repeater1.DataBind();  }  protected void AspNetPager1_PageChanged(object sender, EventArgs e)  {   GetDataBind(Id);  }//根據選擇單選按鈕的不同id,觸發事件  protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)  {    string Id;    Id = RadioButtonList1.SelectedValue;    GetDataBind(Id);  }   }}

TechnologyBLL 層的方法

namespace BTAppBLL{ public class TechnologyBLL {  TechnologyDAL dal = new TechnologyDAL();  public DataTable GetList(int startPage, int pageSize, string where, string orderby)  {   DataTable dTable = dal.GetList(startPage, pageSize, where, orderby);   return dTable;  }  public int GetCountList(string where)  {   int record = dal.GetCountList(where);   return record;  }  public DataTable GetListShow(string TechnologyId)  {   DataTable dTable = dal.GetModel(TechnologyId);   return dTable;  }  public DataTable GetPicture(string TechnologyId)  {   DataTable dTable = dal.GetPicture(TechnologyId);   return dTable;  } }}            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汶上县| 贡觉县| 九台市| 二连浩特市| 青川县| 贡觉县| 萍乡市| 高清| 安康市| 周宁县| 淮安市| 潮安县| 岚皋县| 冷水江市| 东至县| 安吉县| 大丰市| 丹凤县| 仁化县| 盱眙县| 太仓市| 湄潭县| 奈曼旗| 延安市| 长岭县| 黄冈市| 金川县| 航空| 西盟| 沙河市| 大洼县| 兴安盟| 滕州市| 方城县| 黄浦区| 静乐县| 木兰县| 温泉县| 吉木乃县| 左权县| 修文县|