I have a Label within a NestedViewTemplate. I just want to be able to access this Label from my code so I can populate it when the associated row in clicked. I was able to get a reference to it for the first row, but there's got to be a better way... Here's how I'm getting to it from the Grid's OnItemCommand method:
What's the *right* way to do this? I couldn't find any mention of it in the docs or samples...
Thanks!
Eddie
| protected void radGridSample_ItemCommand(object sender, GridCommandEventArgs e) | |
| { | |
| if (e.CommandName == "ExpandCollapse") | |
| { | |
| if (e.Item.Expanded == false) | |
| { | |
| // The line below is where I get the label, but it's too clunky and only works for on GridItem... | |
| Label lblDetail = e.Item.Parent.Controls[4].FindControl("lblDetail") as Label; | |
| if (lblDetail != null) | |
| { | |
| StringBuilder sbDetail = new StringBuilder(); | |
| sbDetail.AppendLine("<div class='Details'>bla bla bla</div>"); | |
| lblDetail.Text = sbDetail.ToString(); | |
| } | |
| } | |
| } | |
| } | |
Thanks!
Eddie