You can specify how row selection is persisted when the GridView control is in paging mode. By default, row selection is persisted by row index. For example, if the second row in a page is selected, the second row in all pages will be selected.
Alternatively, you can specify that row selection is persisted by data-row key. In that case, when a row is selected, rows in other pages are not selected. To enable this functionality, set the EnablePersistedSelection property to true as shown in the following example:
<asp:GridView id="GridView1" runat="server" PersistedSelection="true">
</asp:GridView>
Blog that contains articles about new technologies related or not with programming. I will describe and solves some problems that I encounter in my career. ASP .NET, AJAX, Javascript, C++, C# and SQL are some of the subjects that will appear.
20 August 2012
datarow to dataset in asp
DataTable dt = (DataTable)ViewState["tabData"];
DataRow[] dr = dt.Select("test_cd='899'");
DataSet dsnew = new DataSet();
DataTable dtnew = dt.Clone();
dtnew.Constraints.Clear();
DataRow drnew = dtnew.NewRow();
drnew.ItemArray = dr[0].ItemArray;
dtnew.Rows.Add(drnew);
dsnew.Tables.Add(dtnew);
DataRow[] dr = dt.Select("test_cd='899'");
DataSet dsnew = new DataSet();
DataTable dtnew = dt.Clone();
dtnew.Constraints.Clear();
DataRow drnew = dtnew.NewRow();
drnew.ItemArray = dr[0].ItemArray;
dtnew.Rows.Add(drnew);
dsnew.Tables.Add(dtnew);
15 August 2012
Query to attaching of database using only .mdf file without associated log file
CREATE DATABASE ... FOR ATTACH_REBUILD_LOG
with log file: CREATE DATABASE ... FOR ATTACH
with log file: CREATE DATABASE ... FOR ATTACH
Order of the sqlquery that logically processed
What is the order of execution in the following list?
A: from,where,group by,having,select,order by
ref: http://msdn.microsoft.com/en-us/library/ms174149.aspx
- select
- from
- where
- group by
- order by
- having
A: from,where,group by,having,select,order by
ref: http://msdn.microsoft.com/en-us/library/ms174149.aspx
Rename/Alter the column for a table in sqlserver
To add new column: Alter Table TableName add ColName dataType
To alter a column: Alter Table TableName Alter Column ColumnName DataType NULL/NOT NULL
To rename a column:
EXEC sp_rename
@objname = ' TableName. OldColumnName’,
@newname = 'New ColumnName',
@objtype = 'COLUMN'
note: computed columns(col3=col1+col2) doesnt hav a chance to rename, the only way is it has to be dropped and added back
Ex: Alter Table tblAddress Alter Column Address VARCHAR(512) NULL
------------------------------------------------------------------------------------------------
To rename the table name:
sp_RENAME 'TestTable', 'NewTable'
To alter a column: Alter Table TableName Alter Column ColumnName DataType NULL/NOT NULL
To rename a column:
EXEC sp_rename
@objname = ' TableName. OldColumnName’,
@newname = 'New ColumnName',
@objtype = 'COLUMN'
note: computed columns(col3=col1+col2) doesnt hav a chance to rename, the only way is it has to be dropped and added back
Ex: Alter Table tblAddress Alter Column Address VARCHAR(512) NULL
------------------------------------------------------------------------------------------------
To rename the table name:
sp_RENAME 'TestTable', 'NewTable'
14 August 2012
can u set innerjoin for update command?
Update Employee set State = s.StateID
from Employee e
inner join State s on e.State = s.StateName
from Employee e
inner join State s on e.State = s.StateName
Decide whether i/p parameter contains integers or not in sqlserver
IF PATINDEX('%[0-9]%',@val) > 0
print 'i/p value contain integer'
else
print 'Not contain integer'
print 'i/p value contain integer'
else
print 'Not contain integer'
13 August 2012
Insert records (multiple) into a table using single query in sqlserver
create table tblEmp (eid int, ename varchar(20), estatus bit)
sqlserver2005
basic: insert into tblEmp values (0,'emp', 'True')
insert into tblEmp select 1,'emp1','True'
union all select 2,'emp2','True'
union all select 3,'emp3','True'
sqlserver2008
insert into tblEmp values (1,'emp1','True'),(2,'emp2','True'),(3,'emp3','True')
If table not exist in database then:
select * into tblEmp from (select 1 eid,'emp1' ename,'True' estatus) tbltemp
sqlserver2005
basic: insert into tblEmp values (0,'emp', 'True')
insert into tblEmp select 1,'emp1','True'
union all select 2,'emp2','True'
union all select 3,'emp3','True'
sqlserver2008
insert into tblEmp values (1,'emp1','True'),(2,'emp2','True'),(3,'emp3','True')
If table not exist in database then:
select * into tblEmp from (select 1 eid,'emp1' ename,'True' estatus) tbltemp
Subscribe to:
Posts (Atom)