ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事__第1頁
ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事__第2頁
ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事__第3頁
ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事__第4頁
ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事__第5頁
免費預覽已結束,剩余8頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、ASP.NET中RadioButtonList綁定后臺數據后觸發點擊大事_ 本文實例為大家分享了RadioButtonList綁定后臺數據,觸發點擊大事的方法 首從前臺頁面放置一個RadioButtonList 控件 asp:RadioButtonList runat=server ID=RadioButtonList1 BorderStyle=None RepeatColumns=3 CssClass= RepeatLayout=Flow AutoPostBack=true OnSelectedIndexChanged=RadioButtonList1_SelectedIndexChange

2、d /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.QueryStringId != null) Id = Request.QueryStringId; else Id = ; GetDataBind

3、(Id); DropDownListDataBind(); /RadioButtonList綁定后臺數據 private void DropDownListDataBind() ExpertInfoBLL bll = new ExpertInfoBLL(); DataTable dt = bll.GetDepInfo(); foreach (DataRow dr in dt.Rows) RadioButtonList1.Items.Add(drName.ToString();/循環讀出數據庫的數據 this.RadioButtonList1.DataSource = dt; this.Radi

4、oButtonList1.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 (

5、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; th

6、is.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 層的方法 names

7、pace 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 =

8、 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; TechnologyDAL層的方法 namespace BTAppD

9、AL public class TechnologyDAL public DataTable GetList(int startPage, int pageSize, string where, string orderby) string strSql = string.Format(SELECT a.TechnologyId,a.TechnologyName,a.Summarize,a.Effect,a.MainPoint,a.AppropriateArea,a.Attention,a.CreateTime,a.CreatUser,a.UpdateTime,b.Name FROM Tech

10、nology AS a n + left join Sys_DepInfo AS b ON a.Depinfo_Id=b.Id n + where a.IsActive=1 and 0 , where); string proc = proc_CommonPagerWithStatement; SqlConnection con = SqlDbHelper.Connection; SqlParameter sp = new SqlParameter(intStartIndex, startPage), new SqlParameter(intPageSize, pageSize), new S

11、qlParameter(varStatement, strSql), new SqlParameter(varSortExpression, orderby+ DESC) ; DataTable dt = SqlDbHelper.GetDataSet(proc, sp, con); return dt; public int GetCountList(string where) int countRecord = 0; string strSql = string.Format(select COUNT(TechnologyId) as countRecord from(SELECT a.Te

12、chnologyId,a.TechnologyName,a.Summarize,a.Effect,a.MainPoint,a.AppropriateArea,a.Attention,a.CreateTime,a.CreatUser,a.UpdateTime,b.Name FROM Technology AS a n + left join Sys_DepInfo AS b ON a.Depinfo_Id=b.Id n + where a.IsActive=1 and 0 ) as c, where); SqlConnection con = SqlDbHelper.Connection; tr

13、y if (con.State = System.Data.ConnectionState.Closed) con.Open(); DataTable dt = SqlDbHelper.GetDataTable(strSql); if (dt.Rows.Count 0) countRecord = int.Parse(dt.Rows0countRecord.ToString(); catch (Exception) throw; finally if (con.State = ConnectionState.Open) con.Close(); return countRecord; publ

14、ic DataTable GetModel(string TechnologyId) string strSql = string.Format(SELECT a.TechnologyId,a.TechnologyName,a.Summarize,a.Effect,a.MainPoint,a.AppropriateArea,a.Attention,a.CreateTime,a.CreatUser,a.UpdateTime,b.Name FROM Technology AS a n + left join Sys_DepInfo AS b ON a.Depinfo_Id=b.Id n + whe

15、re a.IsActive=1 and a.TechnologyId = 0 , TechnologyId); DataTable dataTable = SqlDbHelper.GetDataTable(strSql); return dataTable; public DataTable GetPicture(string TechnologyId) string strSql = string.Format(SELECT TOP 5 a.Files_Id,a.Files_Name,a.Files_Path FROM dbo.Com_Files AS a n + LEFT JOIN dbo

16、.Technology AS b ON a.ForeignKey_Id=b.TechnologyId n + WHERE b.IsActive=1 and a.ForeignKey_Id = 0 , TechnologyId); DataTable dataTable = SqlDbHelper.GetDataTable(strSql); return dataTable; ExpertInfoBLL 層的方法 public DataTable GetDepInfo() DataTable dTable = dal.GetDepInfo(); return dTable; ExpertInfoDAL層的方法 public DataTable GetDepInfo() try StringBuilder str = new StringBuilder(SELECT Id,Name FROM dbo.Sys_DepInfo WHERE Is_Active=1 AND DepinfoType=1); DataTable data = SqlDbHelper.GetDataTable(str.ToString(); if (data.Rows.Count 0) return data; else return null; catch (Exception) return null;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論