欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2016年05月11日 10:31:45   作者:wangjingjing1014  
這篇文章主要介紹了ASP.NET中RadioButtonList綁定后臺(tái)數(shù)據(jù)后觸發(fā)點(diǎn)擊事件的相關(guān)資料,感興趣的小伙伴們可以參考一下

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

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

<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ù)

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ù)庫(kù)的數(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ù)庫(kù)返回結(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 層的方法

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層的方法

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 層的方法

 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;
   }
  }

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

 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
  {
    string Id;
    Id = RadioButtonList1.SelectedValue;
    GetDataBind(Id);
  }

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

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

相關(guān)文章

  • ASP.NET?MVC實(shí)現(xiàn)下拉框多選

    ASP.NET?MVC實(shí)現(xiàn)下拉框多選

    這篇文章介紹了ASP.NET?MVC實(shí)現(xiàn)下拉框多選的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-09-09
  • 淺談ASP.NET Core 2.0 部分視圖(譯)

    淺談ASP.NET Core 2.0 部分視圖(譯)

    本篇文章主要介紹了淺談ASP.NET Core 2.0 部分視圖(譯),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-11-11
  • ASP.NET數(shù)據(jù)綁定之DataList控件實(shí)戰(zhàn)篇

    ASP.NET數(shù)據(jù)綁定之DataList控件實(shí)戰(zhàn)篇

    這篇文章主要為大家介紹了ASP.NET數(shù)據(jù)綁定中的DataList控件,DataList控件以表的形式呈現(xiàn)數(shù)據(jù),通過該控件,您可以使用不同的布局來顯示數(shù)據(jù)記錄,對(duì)DataList控件感興趣的小伙伴們可以參考一下
    2016-01-01
  • ASP.NET開發(fā)中經(jīng)常用到10款工具軟件介紹

    ASP.NET開發(fā)中經(jīng)常用到10款工具軟件介紹

    從事.NET開發(fā)也好幾年了,工作過程中積累一些軟件工具,分享給大家,排名不分先后,希望對(duì)大家有所幫助。
    2016-04-04
  • asp.net使用ajaxFileUpload插件上傳文件(附源碼)

    asp.net使用ajaxFileUpload插件上傳文件(附源碼)

    本文詳細(xì)講解了asp.net使用ajaxFileUpload插件上傳文件,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-12-12
  • 通用?HTTP?簽名組件的另類實(shí)現(xiàn)方式

    通用?HTTP?簽名組件的另類實(shí)現(xiàn)方式

    這篇文章主要介紹了通用?HTTP?簽名組件的另類實(shí)現(xiàn)方式,實(shí)現(xiàn)思路大概是采用鏈?zhǔn)秸{(diào)用的方式,使得簽名的步驟可以動(dòng)態(tài)拼湊組合,本文結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09
  • 在?.NET?中使用?FixedTimeEquals?應(yīng)對(duì)計(jì)時(shí)攻擊的例子

    在?.NET?中使用?FixedTimeEquals?應(yīng)對(duì)計(jì)時(shí)攻擊的例子

    在計(jì)算機(jī)安全中,計(jì)時(shí)攻擊(Timing attack)是旁道攻擊 (Side-channel attack) 的一種,而旁道攻擊是根據(jù)計(jì)算機(jī)處理過程發(fā)出的信息進(jìn)行分析,這篇文章主要介紹了在?.NET?中使用?FixedTimeEquals?應(yīng)對(duì)計(jì)時(shí)攻擊,需要的朋友可以參考下
    2022-06-06
  • asp.net 刪除MFC單文檔默認(rèn)菜單欄的兩種方法

    asp.net 刪除MFC單文檔默認(rèn)菜單欄的兩種方法

    新建一個(gè)MFC單文檔程序,默認(rèn)都有四個(gè)菜單欄:文件、編輯、視圖和幫助。怎么把這四個(gè)菜單欄刪除掉呢?
    2010-03-03
  • asp.net 分頁(yè)顯示數(shù)據(jù)表的數(shù)據(jù)的代碼

    asp.net 分頁(yè)顯示數(shù)據(jù)表的數(shù)據(jù)的代碼

    asp.net顯示第一頁(yè)、上一頁(yè)、下一頁(yè)和最后一頁(yè)的分頁(yè)顯示數(shù)據(jù)表的數(shù)據(jù)
    2010-03-03
  • ASP.NET MVC中圖表控件的使用方法

    ASP.NET MVC中圖表控件的使用方法

    這篇文章主要介紹了ASP.NET MVC中圖表控件的使用方法,需要的朋友可以參考下
    2015-10-10

最新評(píng)論