Showing posts with label formview. Show all posts
Showing posts with label formview. Show all posts

Saturday, March 24, 2012

the DataBound event of FormView

hey

asp.net 2.0

I want to programmatically populate (with data from the database) a label
control in a FormView on a webpage.

Is it a good idea to put my logic inside the DataBound event of the
FormView?

any other suggestions?

JeffThe basic databinding pattern with a FormView is the same as with similar
Databound controls such a GridView. Assuming that all your controls (inluding
the label) have their databound field set,

private void BindData()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Users",
myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
fv1.DataSource = ds;
fv1.DataBind();
FormViewRow row = fv1.Row;

}

You could call the above method inside an if(!Page.IsPostBack) check in your
Page_Load handler.

--Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Jeff" wrote:

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I want to programmatically populate (with data from the database) a label
control in a FormView on a webpage.
>
Is it a good idea to put my logic inside the DataBound event of the
FormView?
>
any other suggestions?
>
Jeff
>
>
>


Hey Peter!

thanks for your reply!

But I want to manipulate the data returned from the database before I set
display it in the FormView!

Instead of doing this:
<asp:TextBox ID="helloworldTextBox" runat="server" Text='<%#
Bind("helloworld") %>'>
</asp:TextBox><br />

I want to do something like this (in the code behind page):
helloworldTextBox.text = <db value>;

It's an interesting code you sent me, but I have this already configured. I
want to programmatically manipulate the data returned from db before I show
in the label control

Any suggestions?

"Peter Bromberg [C# MVP]" <pbromberg@dotnet.itags.org.yahoo.nospammin.comwrote in message
news:4C96A67E-E381-4F1C-B90B-0CA19F9C9326@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

The basic databinding pattern with a FormView is the same as with similar
Databound controls such a GridView. Assuming that all your controls
(inluding
the label) have their databound field set,
>
private void BindData()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Users",
myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
fv1.DataSource = ds;
fv1.DataBind();
FormViewRow row = fv1.Row;
>
>
}
>
You could call the above method inside an if(!Page.IsPostBack) check in
your
Page_Load handler.
>
>
--Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Jeff" wrote:
>

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>I want to programmatically populate (with data from the database) a label
>control in a FormView on a webpage.
>>
>Is it a good idea to put my logic inside the DataBound event of the
>FormView?
>>
>any other suggestions?
>>
>Jeff
>>
>>
>>


This is the manipulation I need done to the db data:
String str = reader.GetString(4);
lblInfo.Text = str.Replace(Environment.NewLine, "<br/>");

Maybe I instead could do this data manipulation directly in the stored
procedure (sql server 2005) which returns the datasource to the FormView??

"Peter Bromberg [C# MVP]" <pbromberg@dotnet.itags.org.yahoo.nospammin.comwrote in message
news:4C96A67E-E381-4F1C-B90B-0CA19F9C9326@dotnet.itags.org.microsoft.com...

Quote:

Originally Posted by

The basic databinding pattern with a FormView is the same as with similar
Databound controls such a GridView. Assuming that all your controls
(inluding
the label) have their databound field set,
>
private void BindData()
{
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM Users",
myConnection);
DataSet ds = new DataSet();
ad.Fill(ds);
fv1.DataSource = ds;
fv1.DataBind();
FormViewRow row = fv1.Row;
>
>
}
>
You could call the above method inside an if(!Page.IsPostBack) check in
your
Page_Load handler.
>
>
--Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
>
>
>
>
"Jeff" wrote:
>

Quote:

Originally Posted by

>hey
>>
>asp.net 2.0
>>
>I want to programmatically populate (with data from the database) a label
>control in a FormView on a webpage.
>>
>Is it a good idea to put my logic inside the DataBound event of the
>FormView?
>>
>any other suggestions?
>>
>Jeff
>>
>>
>>

Thursday, March 22, 2012

the formview and delete record

hey all,
on the formview you know how there's the capability to delete that record,
well what's the best way to add a confirm delete dialog box?
thanks,
rodcharParis Hilton and Angelina Jolie Tormented By Cowgirls!
http://www.shockingonline.com/PlayMovie.asp?id=1673286
Carmen Electra and Jennifer Aniston In The Countryside!
http://www.shockingonline.com/PlayM...p?watch=1673286
Catherine Z. Jones and Ashlee Simpson , Weird Lesbian Sex Act!
http://www.shockingonline.com/e?id=1673286
Carmen Electra and Jessica Simpson Teenage And Mature Lesbians Having Sex!
http://www.shockingonline.com/Player.mpeg?q=1673286
Mariah Carey and Ashlee Simpson Have Fun!
http://www.shockingonline.com/Watch?id=1673286
free adult sexasian searcher sexparis hilton new sex videohot teen lesbian sexsex tip for str
aight woman from a gay man
http://akeihjc2.t35.com/sex-movie/f...-sex-movie.htmlhttp://tdmiqyst.t35.com/free-sex-vi...r />
ideo.htmlhttp://bfaqolfz.t35.com/black-sex/b...free-video.htmlhttp://slw7pl0p.t3
5.com/tee...ex-gallery.htmlhttp://bfaqolfz.t35.com/black-sex/m... />
k-sex.html