Adding OnRowDataBound to GridView in Code Behind

Posted on 2009-02-10
Medium Priority
Last Modified: 2013-12-17
I am dynamically creating a gridview in the code behind and need to add a OnRowDataBound event, how do i do this??? i cant seem to find any example on this
Question by:Steege
  • 2
LVL 16

Accepted Solution

burakiewicz earned 2000 total points
ID: 23603745
when you create the new datagrid add this
gvCurrent.RowDataBound += new GridViewRowEventHandler(gvCurrent_RowDataBound);

then add a  event handler like this

protected void gvCurrent_RowDataBound(object sender, GridViewRowEventArgs e)
LVL 16

Expert Comment

ID: 23603756
if you post some code i can show you where to put it

Expert Comment

ID: 23605211
Hello Steege,

as burakiewicz told you, if you post some code we can help you more,
i've attached a sample code for the datarowbound below. hope it helps.


Mohamed Allam
Senior Application Developer
public void grid_RowDataBound(object sender,GridViewRowEventArgs e)
     if (e.Row.RowType == DataControlRowType.DataRow)
         TextBox t = (TextBox) e.Row.FindControl("TextBox85");
         t.Text = System.DateTime.Now.ToShortDateString();

Open in new window


Author Closing Comment

ID: 31545195
Do i feel stupid so i  was going to post my code then i realized i was creating a datagrid not a grid view...dooh! now i just need to figure out how to add the columns to it. Thanks for the help

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question