Friday, March 28, 2008

CheckBox in GridView

Add Gridview Control from the ToolBox
once its placed,click on source tab from VSS,there you can see the rendered html tags for the control.
Between closed Gridview tag,add these tags.In itemtemplate portion,you can add anything like button,image,hyperlink etc..each control will be tie-up with record which binded on Gridview.
Actually,this gridview its quite useful for reporting view.Simply we can call the minimal crystalreport for web application.
if you want to view the individual invoice detail on the Bill listing can add hyper link control to GridView,then you make some piece of codeto retrieve the details for corresponding invoice number.
secondly,If there is situation where user has to select multiple choices from the GridviewReport.we go for checkbox option.
Added checkboxes bind with GridViews.
If you wish to select the each row in gridview and find the selected row's value.then code will be,

foreach (GridViewRow row in GridView1.Rows)
CheckBox chb = (CheckBox)row.FindControl("friend");
//You need to identify the control which fired on GridView
if(chb.Checked = true)
selValue= (row.Cells[1].Text) + ',';
I hope this simple explanation will help you to go further up on this !

Saturday, March 01, 2008

C# - Types of function and Enumeration

It allows you to create your own data types.You can't declare the enum in the main block because it cant execute,its only a definition so youmust place it out of main.each value in enumeration can accept a storage type which is int by default.
enum days
using the enum value in main method.
days d;
Response.Write(d); // friday
Function call by Ref:
Compiler doesnt want to create temprory variable for the parameters of the function.So less overhead and tremendous functionality available while using this function.It uses the same value in the calling function.
out parameter function.
An function can return only one value at the time of execution.If you require more than on value return by the function,you can pass the out parameter to your function.out varialble must be unassigned declared.

public int MuruOutParameter(out int x)
int y=5;
int x=6;
Call the function in the main
int p;
Console.WriteLine(MuruOutParameter(out p)
output : 6