Solved

Why not seen OnDataBound event?

Posted on 2013-02-01
4
303 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
esolve earned 100 total points
ID: 38846171
0
 
LVL 10

Author Comment

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

Expert Comment

by:esolve
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()))
                    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
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
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

739 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