Solved

Why not seen OnDataBound event?

Posted on 2013-02-01
4
294 Views
Last Modified: 2013-02-02
Hi,
Can you please advise why I can't find out OnDataBound event below for Formview?
http://dl.dropbox.com/u/40211031/t321.png
0
Comment
Question by:HuaMinChen
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
esolve earned 100 total points
Comment Utility
0
 
LVL 10

Author Comment

by:HuaMinChen
Comment Utility
Many thanks. Is there any event similar to OnDataBound for a formview?
0
 
LVL 6

Expert Comment

by:esolve
Comment Utility
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()))
                    return;
            }
        }

Open in new window


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

Assisted Solution

by:Monica P
Monica P earned 50 total points
Comment Utility
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
http://www.vkinfotek.com/formview/formview-databound-event.html

http://forums.asp.net/t/1496151.aspx/1

http://forums.asp.net/t/1076485.aspx/1
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now