Tuesday, January 22, 2008

Gridview AutoNumber

Today im looking code for autonumber in gridview..Luckily i found this website
but in thailand language with c# code..its not a big deal..the source blog refer from forum exchange that premium membership only can post huhu..so here the code;-

protected void gvAttDoc_RowDataBound(object sender, GridViewRowEventArgs e){//check viewstate ถ้า dt = 0 ไม่ต้องทำ –

if (e.Row.RowType == DataControlRowType.DataRow){int ii = e.Row.RowIndex + 1;e.Row.Cells[0].Text = ii.ToString();}

}

——-

so to sum it up to do this properly the code needed for the .cs page is:

protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)

And the code for the aspx page is inserted just after the tag:







{
Label lblNumber = (Label)e.Row.FindControl(”lblNumber”);
lblNumber.Text = (e.Row.RowIndex + 1).ToString();

}
}


_________________




<%#Eval("f_id_personal1")%>


If e.Row.RowType = DataControlRowType.DataRow Then
Dim lblNumber As Label
lblNumber = e.Row.FindControl("lblNumber")
lblNumber.Text = (e.Row.RowIndex + 1).ToString()
End If


1 comment:

Anonymous said...

Hello,

When ever I surf on web I come to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]thalz142.blogspot.com is filled with quality info. Let me tell you one thing guys, some time we really forget to pay attention towards our health. Here is a fact for you. Recent Research presents that almost 90% of all U.S. adults are either chubby or weighty[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] So if you're one of these people, you're not alone. Its true that we all can't be like Brad Pitt, Angelina Jolie, Megan Fox, and have sexy and perfect six pack abs. Now next question is how you can achive quick weight loss? [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss[/url] is not like piece of cake. Some improvement in of daily activity can help us in losing weight quickly.

About me: I am author of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for quick weight loss.

Locations of visitors to this page
DROP ME A MSG :D