Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Default Value to TexBox in ListView ASP.NET

Status
Not open for further replies.

mhamlett

Programmer
Oct 20, 2014
10
US
I have tried many solutions found online that seemed to work for others but not working for me, can someone please tell me if there is something else I have to do to make this work?
I simply need to add default value to TextBox when using ListView.

online example 1:

protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
TextBox DateAssignedTextBox = (TextBox)e.Item.FindControl("DateAssignedTextBox");
DateAssignedTextBox.Text = DateTime.Now.ToString();
}

online example 2:

protected void ListView1_DataBound(object sender, EventArgs e)
{
TextBox tb = (TextBox)ListView1.InsertItem.FindControl("TextBox1");
tb.Text = "any_text";
}

online example 3:

((TextBox)myDetailsView.InsertItem.FindControl("TextBox1")).Text =
DateTime.Now.ToString("M/d/yyyy HH:mm");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top