Hi Subhadip,
Why you choose to show a output in label ?Just try in gridview...
Any how...based on requirement try this way....
First to get a value from DB into DataTable..
Here dtData --> DataTable
Assign one integer variable in global
int n=0;
Get First Record...
string sText = string.Empty;
for(int nCol=0; nCol<dtData.Columns.Count; nCol++)
{
if(sText ! =string.Empty)
sText +="\r"; // If you want same row means sText += " ";
sText += dtData.Rows[0][nCol].ToString();
n = 0; // In this case user cannot allow to view the Previous record.
}
Get Next Record...
string sText = string.Empty;
for(int nCol=0; nCol<dtData.Columns.Count; nCol++)
{
if(sText ! =string.Empty)
sText +="\r"; // If you want same row means sText += " ";
sText += dtData.Rows[++n][nCol].ToString();
}
Get Previus Record...
string sText = string.Empty;
for(int nCol=0; nCol<dtData.Columns.Count; nCol++)
{
if(sText ! =string.Empty)
sText +="\r"; // If you want same row means sText += " ";
sText += dtData.Rows[--n][nCol].ToString();
}
Get Last Record...
string sText = string.Empty;
for(int nCol=0; nCol<dtData.Columns.Count; nCol++)
{
if(sText ! =string.Empty)
sText +="\r"; // If you want same row means sText += " ";
sText += dtData.Rows[dtData.Rows.Count-1][nCol].ToString();
n=dtData.Rows.Count-1; // In this case user cannot allow to view the next record.
}
After looping set string value into your label
Label1.Text = sText;
Cheers :)
Thanks,
T.Saravanan
Subhadip, if this helps please login to Mark As Answer. | Alert Moderator