Tuesday, April 28, 2009

How to get selected or current row from a gridview? How can i retrieve the hidden coloumns value from selected gridview row?

How to get current selcted row index in GridView?
I saw many people are struggling to get the current selected row when the rowcommand event.
In asp.net 2.0 row comand will be like this

protected void gridcommand(object sender, GridViewCommandEventArgs e)
here you can't get any property like e.RowIndex or e.Keys

But if you look at other specific event like OnRowUpdating OnRowDeleted ,properties like e.RowIndex or e.Keys are available so it will be easy to retrieve the values.you dont have to worry about this there is work around for getting this values in the command event ,i know that if you are using Gridview then you will definetly come across situation where you need to use the command event other than normal edit update and delete events.
thfollowing code sample will help you to retrieve those

protected void gridcommand(object sender, GridViewCommandEventArgs e) { GridViewRow row = (GridViewRow)((Control)e.CommandSource).Parent.Parent; GridView gv = (GridView)(e.CommandSource); string s = gv.DataKeys[row.RowIndex][0].ToString(); }

Wednesday, April 1, 2009

Build In Visual Studio

There are two type of compilers used for compiling
1. Visual Studio comes with a in-process compiler, or in-proc compiler.
2. In the .NET Framework we also ship a separate compiler: the framework compiler, CSC.EXE.

The downside of using the in-proc compiler is that it limits scalability. The Visual Studio address space is pretty crowded, and compiling large projects takes up a lot of address space. This wouldn't be a concern if Visual Studio spawned CSC.EXE for the build. So if you run into build scalability issues with a Visual Studio full build, you can often work around them by invoking MSBUILD.EXE from the command line supplying the .SLN file.

First Approach
So if you want to use the compiler comes with .Net Framework then change the setting of UseHostCompilerIfAvailable property in your project (.csproj) file to false (it defaults to true). Just put the following in the first PropertyGroup element at the top of your project file

<UseHostCompilerIfAvailable>false</UseHostCompilerIfAvailable>

Second Approach
"%SystemRoot%\Microsoft.NET\Framework\v3.5\msbuild.exe" "..\MysampleProject.sln" /p:"Platform=Mixed Platforms" /p:Configuration=Debug /t:rebuild /maxcpucount:20