使得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();