webgrid操作
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
function Save() {
var grid = igtbl_getGridById( " dgList " );
var rows = igtbl_getGridById( " dgList " ).Rows;
// grid.getActiveCells();
// var hTbl = grid.GetRootTable().getElement();
// var rows = hTbl.rows;
for (var i = 0 ; i < rows.length; i ++ ) {
var row_i = rows.getRow(i).getCellFromKey( " STANDARD_TYPE_NAME " ).getValue();
for (var j = i + 1 ; j < rows.length; j ++ ) {
var row_j = rows.getRow(j).getCellFromKey( " STANDARD_TYPE_NAME " ).getValue();
if (row_i == row_j)
{
alert( ' 第 ' + (i + 1 ) + ' 行与第 ' + (j + 1 ) + ' 行相同 ' );
return false ;
}
}
}
alert( ' 保存成功 ' );
return true ;
}
var grid = igtbl_getGridById( " dgList " );
var rows = igtbl_getGridById( " dgList " ).Rows;
// grid.getActiveCells();
// var hTbl = grid.GetRootTable().getElement();
// var rows = hTbl.rows;
for (var i = 0 ; i < rows.length; i ++ ) {
var row_i = rows.getRow(i).getCellFromKey( " STANDARD_TYPE_NAME " ).getValue();
for (var j = i + 1 ; j < rows.length; j ++ ) {
var row_j = rows.getRow(j).getCellFromKey( " STANDARD_TYPE_NAME " ).getValue();
if (row_i == row_j)
{
alert( ' 第 ' + (i + 1 ) + ' 行与第 ' + (j + 1 ) + ' 行相同 ' );
return false ;
}
}
}
alert( ' 保存成功 ' );
return true ;
}
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
protected
void
btnSave_Click(
object
sender, EventArgs e)
{
DataSet staType = dal.STANDARD_TYPE_MANAGE_LIST();
for ( int i = 0 ; i < this .dgList.Rows.Count; i ++ )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ) == null || this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text == null )
{
for ( int j = 0 ; j < staType.Tables[ 0 ].Rows.Count; j ++ )
{
if (dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text == staType.Tables[ 0 ].Rows[j][ " STANDARD_TYPE_NAME " ].ToString())
{
dgList.Rows[i].Cells.Clear();
}
}
}
}
for ( int i = 0 ; i < this .dgList.Rows.Count; i ++ )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ) == null || this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text == null )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text != null )
{
int out_id = - 1 ;
dal.STANDARD_TYPE_ADD( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text, out out_id);
}
}
else
{
dal.STANDARD_TYPE_UPDATE(Int32.Parse( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text), this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text);
}
}
string [] str = this .txtDeldg.Text.Split( ' $ ' );
for ( int j = 0 ; j < str.Length; j ++ )
{
if (str[j].Trim().Length > 0 )
{
dal.STANDARD_TYPE_DEL(Int32.Parse(str[j]));
}
}
BindData();
// ETime.Web.JavascriptHelper.MessageBox(this, "保存成功");
Response.Write( " <script>window.returnValue=1;window.open=null;window.close();</script> " );
}
{
DataSet staType = dal.STANDARD_TYPE_MANAGE_LIST();
for ( int i = 0 ; i < this .dgList.Rows.Count; i ++ )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ) == null || this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text == null )
{
for ( int j = 0 ; j < staType.Tables[ 0 ].Rows.Count; j ++ )
{
if (dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text == staType.Tables[ 0 ].Rows[j][ " STANDARD_TYPE_NAME " ].ToString())
{
dgList.Rows[i].Cells.Clear();
}
}
}
}
for ( int i = 0 ; i < this .dgList.Rows.Count; i ++ )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ) == null || this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text == null )
{
if ( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text != null )
{
int out_id = - 1 ;
dal.STANDARD_TYPE_ADD( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text, out out_id);
}
}
else
{
dal.STANDARD_TYPE_UPDATE(Int32.Parse( this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_ID " ).Text), this .dgList.Rows[i].Cells.FromKey( " STANDARD_TYPE_NAME " ).Text);
}
}
string [] str = this .txtDeldg.Text.Split( ' $ ' );
for ( int j = 0 ; j < str.Length; j ++ )
{
if (str[j].Trim().Length > 0 )
{
dal.STANDARD_TYPE_DEL(Int32.Parse(str[j]));
}
}
BindData();
// ETime.Web.JavascriptHelper.MessageBox(this, "保存成功");
Response.Write( " <script>window.returnValue=1;window.open=null;window.close();</script> " );
}