Why not seen OnDataBound event?

Posted on 2013-02-01
Last Modified: 2013-02-02
Can you please advise why I can't find out OnDataBound event below for Formview?
Question by:HuaMinChen
  • 2

Accepted Solution

esolve earned 100 total points
ID: 38846171
LVL 10

Author Comment

ID: 38846186
Many thanks. Is there any event similar to OnDataBound for a formview?

Expert Comment

ID: 38846234
I suppose you could use the Databound and Databinding event.

The Databound event fires after the control binds to a source. So you could use this event to retrieve the datarowview like this.

 protected void FormView1_DataBinding(object sender, EventArgs e)
            FormView frm = (FormView)sender;

            DataRowView drv = (DataRowView)frm.DataItem;
            for (int i = 0; i < drv.DataView.Table.Columns.Count; i++)
                if (!string.IsNullOrEmpty(drv[i].ToString()))

Open in new window

You can access a control like this:
Label Label4 = (Label)FormView1.FindControl("Label4");
Label4.Text = price.ToString("c");
LVL 10

Assisted Solution

by:Monica P
Monica P earned 50 total points
ID: 38846534
protected void ItemsFormView_DataBound(object sender, EventArgs e)
       DataRowView dataRow = ((DataRowView)FormView1.DataItem);
        if (Convert.ToInt16(dataRow["ClStk"]) <= 0)
            Label lbl = (Label)FormView1.FindControl("lblStock");
                 lbl.CssClass = "changefont";

Link with sample of bound event

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity winforms sizing/resolution? 4 45
VS 2017 18 55
Code enhancement 4 22
ASP.NET MVC -Update model when click on <li> element 29 37
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System ( introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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 …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

830 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