I'm still trying to get www.asp.net to include ASP.NET 3.5 For Dummies in their Starter Books section. Not sure what's going on there. They list other Dummies books, so it can't be an anti-Dummies thing.
In the meantime, here are a couple of kind reader comments that made my day!
"I just read your book cover to cover. It was one of the best written books I have ever read. The amount of work you put into it must have been massive. I loved it!" --MW
"The book is very well written & understandable!" --BHS
There's also a review on Amazon.com.
<rant>
I'm spending hours trying to get a reference to a FileUpload control that's inside an InsertTemplate which is inside a Panel which is inside a Listview which is inside a Panel in an ASP.NET ContentPlaceHolder.
It's crazy to have to figure out all these naming containers (and parents, grandchildren, cousins, and in-laws) manually when ASP.NET creates the control structure and knows perfectly well where things are and what they're called.
Therefore, it would be nice to have a better FindControl method that would automatically (using LINQ?) do the recursion to come up with the control reference. You'd just pass in the control ID as a string.
When I look at the browser DOM's document.getElementId("txtJLLAmt1") I have to think this could be built into ASP.NET. Here's a post with the basic idea that the ASP.NET Team could build on:
http://weblogs.asp.net/dfindley/archive/2007/06/29/linq-the-uber-findcontrol.aspx
</rant>
Thanks for listening. I feel better having ranted - even though I don't have the problem solved.
Ken
I went around in circles on these issues, so maybe this post will help someone else. I still haven't got a handle on what's going on. Maybe a wise and knowledgeable reader will add a comment and flesh this out. If it makes a difference, I'm using the ObjectDataSource.
My goal was to get the value of a checkbox control inside a ListView
<EditItemTemplate>. For some strange reason, the compiler complains about Bind() in the declarative markup for certain controls but not others. For those, the best you can get in the markup is Eval(), used like this:
<asp:CheckBox ID="chkIS_DEFAULT" runat="server"
Checked='<%# Convert.ToBoolean(Eval("IS_DEFAULT")) %>' />
This means you have to bind the control using code, which is pretty weird as well. But what's even more bizarre is the way you need to jam in the value within the ListView control's ItemUpdating event:
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
// To get the checkbox value (can't be done declaratively) --kc
CheckBox chk;
chk = ListView1.Items[e.ItemIndex].FindControl("chkIS_DEFAULT") as CheckBox;
if (chk != null)
{
e.NewValues["IS_DEFAULT"] = chk.Checked.ToString().ToUpper();
}
}
The ListViewUpdateEventArgs class is really different from its insertion counterpart, ListViewInsertEventArgs. Within the <InsertItemTemplate>, I was able to do it like this:
protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
CheckBox chk = e.Item.FindControl("chkIS_DEFAULT") as CheckBox;
if (chk != null)
{
e.Values["IS_DEFAULT"] = chk.Checked.ToString().ToUpper();
}
}
This is all quite baffling. I'd like to blame in on C# idiocy (I'm a VB fan) but I'm sure there's a good explanation (bug??) for the nonsense.
Just for good measure, here's what I had to do to get the value from a dropdownlist control:
protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
DropDownList ddl2 = e.Item.FindControl("ddlSTATUS") as DropDownList;
if (ddl != null)
{
e.Values["STATUS"] = ddl2.SelectedValue.ToString();
}
}
What's up with all this?
Ken
MVP [ASP.NET]
Wow! A load of goodies today!
http://www.microsoft.com/downloads/details.aspx?FamilyID=e0bae58e-9c0b-4090-a1db-f134d9f095fd&DisplayLang=en
This package is an add-on to the RTM release of Visual Studio 2008 to provide tooling for Microsoft Silverlight 2 Beta 1. It provides a Silverlight project system for developing Silverlight applications using C# or Visual Basic.
This download will install the following:
- Silverlight 2 Beta 1
- Silverlight 2 SDK Beta 1
- KB949325 for Visual Studio 2008
- Silverlight Tools Beta 1 for Visual Studio 2008
Silverlight Tools Beta 1 for Visual Studio 2008 includes:
- Visual Basic and C# Project templates
- Intellisense and code generators for XAML
- Debugging of Silverlight applications
- Web reference support
- Integration with Expression Blend
Check it out!
"The ASP.NET 3.5 Extensions Preview is a preview of new functionality being added to ASP.NET 3.5 and ADO.NET. The release includes ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET controls for Silverlight, ADO.NET Data Services, Entity Framework runtime, and new features for ASP.NET AJAX."
http://www.microsoft.com/downloads/details.aspx?FamilyID=a9c6bc06-b894-4b11-8300-35bd2f8fc908&DisplayLang=en