Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi,
i m working with asp.net 4.0.in my app i m using gridview in grid out of 6 column, i need to perform 2 column databaund event.
how i know databaund event fired from which column.
Posted
Comments
bhagirathimfs 21-Aug-12 2:50am    
Can you please explain it briefly??
Varun Sareen 21-Aug-12 7:06am    
Do you want to bind columns at design time to the two columns? Is that so?
Varun Sareen 21-Aug-12 7:13am    
Explain your query in brief..!!

From: Jitu8187
jitu8187 21-Aug-12 9:59am    
Explain your query in brief..!!

1 solution

There is no 'column databound' event, but there is a 'row databound' event in asp.net gridview. Also the databound event is fired only on binding a entire row and not a individual column.

However you can get the 'row databound' event and access the individual column in that row using the column index or name in that row.

Here is the code sample that gives you individual value in a column where 5 is the column index

C#
protected void gvCategory_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[5].Text=="0")
            {
                e.Row.Cells[5].Text = "INACTIVE";
            }
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900