一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - ASP.NET教程 - ASP.NET中RadioButtonList綁定后臺(tái)數(shù)據(jù)后觸發(fā)點(diǎn)擊事件

ASP.NET中RadioButtonList綁定后臺(tái)數(shù)據(jù)后觸發(fā)點(diǎn)擊事件

2020-01-08 13:59wangjingjing1014 ASP.NET教程

這篇文章主要介紹了ASP.NET中RadioButtonList綁定后臺(tái)數(shù)據(jù)后觸發(fā)點(diǎn)擊事件的相關(guān)資料,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了RadioButtonList綁定后臺(tái)數(shù)據(jù),觸發(fā)點(diǎn)擊事件的方法

首先前臺(tái)頁面放置一個(gè)RadioButtonList 控件

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

.cs文件 后臺(tái)綁定數(shù)據(jù)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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綁定后臺(tái)數(shù)據(jù)
  private void DropDownListDataBind()
  {
   ExpertInfoBLL bll = new ExpertInfoBLL();
   DataTable dt = bll.GetDepInfo();
   foreach (DataRow dr in dt.Rows)
   {
    RadioButtonList1.Items.Add(dr["Name"].ToString());//循環(huán)讀出數(shù)據(jù)庫的數(shù)據(jù)
    
   }
   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)
  {
   //這里寫解碼和數(shù)據(jù)庫返回結(jié)果
   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);
   //綁定數(shù)據(jù)
   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);
  }
 
//根據(jù)選擇單選按鈕的不同id,觸發(fā)事件
  protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
  {
    string Id;
    Id = RadioButtonList1.SelectedValue;
    GetDataBind(Id);
  }
  
 }
}

TechnologyBLL 層的方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
  }
 }
}

TechnologyDAL層的方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
namespace BTAppDAL
{
 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 Technology 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 SqlParameter("@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.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" +
    "where a.IsActive='1' and {0} ) as c", where);
   SqlConnection con = SqlDbHelper.Connection;
   try
   {
    if (con.State == System.Data.ConnectionState.Closed)
     con.Open();
    DataTable dt = SqlDbHelper.GetDataTable(strSql);
    if (dt.Rows.Count > 0)
     countRecord = int.Parse(dt.Rows[0]["countRecord"].ToString());
   }
   catch (Exception)
   {
    throw;
   }
   finally
   {
    if (con.State == ConnectionState.Open)
    {
     con.Close();
    }
   }
 
 
   return countRecord;
  }
  public 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" +
    "where 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.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 層的方法

?
1
2
3
4
5
public DataTable GetDepInfo()
 {
  DataTable dTable = dal.GetDepInfo();
  return dTable;
 }

ExpertInfoDAL層的方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
  }
 }

在頁面加載的時(shí)候調(diào)用DropDownListDataBind()方法
觸發(fā)RadioButtonList的點(diǎn)擊事件

?
1
2
3
4
5
6
7
<strong> protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
  {
    string Id;
    Id = RadioButtonList1.SelectedValue;
    GetDataBind(Id);
  }
</strong>

既可以實(shí)現(xiàn)點(diǎn)擊某個(gè)單選按鈕,并觸發(fā)事件。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产二区视频 | 亚洲第一国产 | 成人网欧美亚洲影视图片 | 四虎在线观看 | 亚洲国产cao | 5278欧美一区二区三区 | 青青网站| 美女张开下身让男人桶 | mm131亚洲精品久久 | 精品久久久久久国产91 | 色综合合久久天天综合绕视看 | 欧美透逼视频 | 男人天堂资源网 | 欧美国产日韩在线 | 欧美猛男同志同性video | 校花被拖到野外伦小说 | 好爽好深好猛好舒服视频上 | 30分钟的高清视频在线观看 | 被老头肉至怀孕小说 | 亚洲欧美日韩国产一区二区精品 | 国产高清好大好夹受不了了 | 2012手机在线中文字幕 | 亚洲日本视频在线观看 | 乌克兰17一18处交 | 卫生间被教官做好爽HH视频 | av中文字幕在线 | 好湿好紧太硬了我太爽了h 好湿好滑好硬好爽好深视频 | 欧美图片另类小说综合 | 国内自拍网红在线自拍综合 | 欧美一级v片 | 国产麻豆91网在线看 | 免费精品一区二区三区在线观看 | 成人久久网站 | 白鹿扒开内裤露出尿孔 | 美女天天色 | 亚洲免费小视频 | 蘑菇香蕉茄子绿巨人丝瓜草莓 | 日本福利片国产午夜久久 | 美女视频在线观看视频 | 全程粗语对白视频videos | 色婷婷久久综合中文久久一本 |