欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

怎么在GridView中使用asp.netChecbox-創(chuàng)新互聯(lián)

這篇文章將為大家詳細講解有關怎么在GridView中使用asp.net Checbox,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

成都創(chuàng)新互聯(lián)服務項目包括懷遠網(wǎng)站建設、懷遠網(wǎng)站制作、懷遠網(wǎng)頁制作以及懷遠網(wǎng)絡營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關系等,向廣大中小型企業(yè)、政府機構等提供互聯(lián)網(wǎng)行業(yè)的解決方案,懷遠網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到懷遠省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!
<div >
   <yxy:HkrGridView ID="tabGridView1" runat="server" AutoGenerateColumns="False" Width="100%"
     OnRowDataBound="HkrGridView1_RowDataBound" OnRowCreated="HkrGridView1_RowCreated"
     ShowHeader="True" AllowPaging="false" DataKeyNames="keyId" ShowFooter="false">
     <Columns>
       <asp:BoundField>
         <ItemStyle HorizontalAlign="Center" Width="5%" />
       </asp:BoundField>
       <asp:TemplateField>
       <ItemTemplate>
       <a href='<%#DataBinder.Eval(Container.DataItem,"newName")%>' ><%#DataBinder.Eval(Container.DataItem,"oldName")%></a>
       </ItemTemplate>
       </asp:TemplateField>
     <asp:BoundField DataField="memo">
         <ItemStyle Width="20%" HorizontalAlign="left" />
       </asp:BoundField>
       <asp:TemplateField>
         <ItemTemplate>
           <asp:CheckBox ID="CheckBox" runat="server" />
         </ItemTemplate>
         <ItemStyle HorizontalAlign="Center" Width="5%" />
       </asp:TemplateField>
     </Columns>
     <FooterStyle ForeColor="Red" HorizontalAlign="Center" Font-Bold="true" />
   </yxy:HkrGridView>
   <div id="DivOne" >
     <asp:CheckBox ID="CheckBoxAll" runat="server" Text="全選" Width="80px" AutoPostBack="True"
       OnCheckedChanged="CheckBoxAll_CheckedChanged" />
     <asp:CheckBox ID="CheckBox1" runat="server" Text="反選" Width="80px" AutoPostBack="True"
       OnCheckedChanged="CheckBox1_CheckedChanged" />
     <asp:Button ID="Button1" runat="server" Text="取 消" CssClass="Button" OnClick="Button1_Click" />
   </div>
</div>

后臺代碼:

protected void HkrGridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.Header)
    {
      TableCellCollection tcHeader = e.Row.Cells;
      tcHeader.Clear();
      //第一行表頭
      tcHeader.Add(new TableHeaderCell());
      tcHeader[0].Text = "序號<BR>No.";
      tcHeader.Add(new TableHeaderCell());
      tcHeader[1].Text = "附件名稱";
      tcHeader.Add(new TableHeaderCell());
      tcHeader[2].Text = "備注";
      tcHeader.Add(new TableHeaderCell());
      tcHeader[3].Text = "選擇</tr>";
    }
}
protected void HkrGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    GridViewRow gr = e.Row;
    if (e.Row.RowIndex != -1)
    {
      e.Row.Cells[0].Text = (e.Row.RowIndex + 1).ToString();
    }
}
private void HkrGridViewBind(){
    string strSql = "SELECT keyId,newName, oldName, localHome,memo FROM aq_file_up WHERE (relaid = @relaid) AND (fjType = @fjType) AND (usestatus = 1)";
    SqlParameter[] sps = {
              new SqlParameter("@relaid",this.hdnRelaId.Value),
              new SqlParameter("@fjType",this.hdnFjType.Value)
               };
    DataTable dt = pms.SqlHelper.ExecuteDataTable(CommandType.Text, strSql, sps);
    tabGridView1.DataSource = dt;
    tabGridView1.DataBind();
}
rotected void Button1_Click(object sender, EventArgs e)
{
    CheckBoxAll.Checked = false;
    CheckBox1.Checked = false;
    for (int i = 0; i <= tabGridView1.Rows.Count - 1; i++)
    {
      CheckBox cb = (CheckBox)tabGridView1.Rows[i].FindControl("CheckBox");
      cb.Checked = false;
    }
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
   for (int i = 0; i <= tabGridView1.Rows.Count - 1; i++)
    {
      CheckBox cb = (CheckBox)tabGridView1.Rows[i].FindControl("CheckBox");
      if (cb.Checked == false)
      {
        cb.Checked = true;
      }
      else
      {
        cb.Checked = false;
      }
    }
    //CheckBox1.Checked =true;
    CheckBoxAll.Checked = false;
}
protected void CheckBoxAll_CheckedChanged(object sender, EventArgs e)
{
   for (int i = 0; i <= tabGridView1.Rows.Count - 1; i++)
    {
      CheckBox cb = (CheckBox)tabGridView1.Rows[i].FindControl("CheckBox");
      if (CheckBoxAll.Checked == true)
      {
        cb.Checked = true;
      }
      else
      {
        cb.Checked = false;
      }
    }
    CheckBox1.Checked = false;
}

關于怎么在GridView中使用asp.net Checbox就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

文章名稱:怎么在GridView中使用asp.netChecbox-創(chuàng)新互聯(lián)
URL地址:http://www.chinadenli.net/article32/dcejpc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設微信公眾號外貿(mào)網(wǎng)站建設外貿(mào)建站云服務器品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

h5響應式網(wǎng)站建設