Ralf Eisenreich

SQLBlog.DE | ..things to remember

November 28th, 2007

GridView: FindControl in Template

.Net, ASP.Net, IT, by Ralf.

EditItemTemplate

Um ein erfolgreiches FindControl in einem EditItemTemplate umzusetzen, sollte folgender Code verwendet werden. In diesem Beispiel wird in einem GridView in einer editierbaren Zeile einer Textbox ein Wert (SelectedValue) aus einer DropDownList zugewiesen, sobald ein Button gedrückt wird.


protected void btnSet_Click(object sender, EventArgs e) {
TextBox txtPredecessorName = (TextBox)((Button)sender).Parent.FindControl("txtPredecessorName");
DropDownList ddKTPredecessors = (DropDownList)((Button)sender).Parent.FindControl("ddKTPredecessors");
txtPredecessorName.Text = ddKTPredecessors.SelectedValue;
}

Back Top

Responses to “GridView: FindControl in Template”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Security Code: