To display or fetch data of a cell from GridView use the fallowing steps:
1.Bind the Gridview with Data.
2. Enable Selection in Gridview by using its smart task panel.
3.Double click on the GridView so that it generates the fallowing event:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
4. Now write the fallowing code inside the SelectedIndexChanged event
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
Label1.Text = row.Cells[3].Text;
}
The first line fetches the Data of the Selected Row from the GridView and
the second line displays the 3rd cell data on a Label.
5. Specify the Index of the Cell in Cells[] which you want to display.
6.When you Run the page Select Button is generated with each Row. Press the Select button of the corresponding Row and you will see the respective Cell data on the Label.
Here in the example you see the design page with GridView and a Label.
In the next picture you see the Contact column of 3rd row being displayed on the Label.
Wednesday, January 27, 2010
Monday, January 25, 2010
Setting Breakpoints and Watching Variables in ASP.Net
In Visual Studio you can set a Breakpoint to stop the project at a particular line of code.
Once you set the Breakpoint to a line and you run the project, it will stop the project before executing the line and shows the particular line in the code editor.
To set a Breakpoint click the gray margin to the left of the line where you want to give a break.
The watch window opens only when the debugger is in running mode or break mode.
So open the watch window when the projects halts at the breakpoint through
Debug >> Windows >> Watch and select a watch window.
You can view the value of the variables by just pointing the mouse over the variable and also using the Watch.
If the variable is complex type like arrays or an object you should use the watch window.
To add the variables into watch window just select the variable and drag it to the watch window.
Click the + sign to view the subitems such as array elements or object properties.
Once you set the Breakpoint to a line and you run the project, it will stop the project before executing the line and shows the particular line in the code editor.
To set a Breakpoint click the gray margin to the left of the line where you want to give a break.
The watch window opens only when the debugger is in running mode or break mode.
So open the watch window when the projects halts at the breakpoint through
Debug >> Windows >> Watch and select a watch window.
You can view the value of the variables by just pointing the mouse over the variable and also using the Watch.
If the variable is complex type like arrays or an object you should use the watch window.
To add the variables into watch window just select the variable and drag it to the watch window.
Click the + sign to view the subitems such as array elements or object properties.
Subscribe to:
Posts (Atom)