近期.NET学习及项目开发整理-界面里面的小技巧1 GRIDVIEW 有格子

使得GRIDVIEW 有格子 灰色格子
/*add by xuejiayue for gridview grid*/
table.gridview_m
{
    font-family: 宋体;
    border-collapse: collapse;
    border:solid 1px #93c2f1;
    /*width:50%;*/
    font-size:9pt;
}

table.gridview_m td,th
{
    font-family: 宋体;
    border-collapse: collapse;
    border:solid 1px #93c2f1;
    font-size:9pt;
}


DropDownList1 AutoPostBack 自动回发

下拉菜单里面有 第1行 数据。。。。

this.DropDownList1.Items.Insert(0, new ListItem("-请选择-", "0"));

 

 

//
///
///GIRDVIEW 中 获得的数据
///
//
((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim()
((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim()
GridView1.DataKeys[e.RowIndex].Value.ToString()

///GRIDVIEW 中删除数据时的提醒
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //如果是绑定数据行
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
             if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
            {
                ((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:/"" + e.Row.Cells[1].Text + "/"吗?')");
            }
        }

    }


 

也可以用 DataKeyNames


 

 

有两个关键字DataKeyNames="orgcode,staffcode"

那么后台取数字就用     
 string orgcode = GridView1.DataKeys[e.RowIndex]["orgcode"].ToString().Trim();
 string staffcode = GridView1.DataKeys[e.RowIndex]["staffcode"].ToString().Trim();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值