C
Colin Young
I'm having a bit of a problem with my DataList when I try to update from the
user's input. I've included relevant excerpts at the end of this message. In
the UpdateCommand code, the "PageLevelTextBox" appears to be found (it isn't
returning null), but the Text property is an empty string ("").
Am I missing something really obvious?
Thanks
Colin
private void DeployList_UpdateCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
int PageLevel, ZoneID;
ZoneID = int.Parse(e.CommandArgument.ToString());
TextBox PageLevelTB =
(TextBox)e.Item.FindControl("PageLevelTextBox");
try
{
PageLevel = int.Parse(PageLevelTB.Text);
Distribution dist = new
Distribution(appEnv.GetConnection());
dist.InsertAtEnd(cid, ver, ZoneID, PageLevel);
DeployList.EditItemIndex = -1;
Bind();
}
catch(Exception ex)
{
Controls.Add(new LiteralControl(ex.Message));
}
}
<edititemtemplate>
<div class="row">
<span class="label" style="width: 35%; text-align: left; ">
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</span>
<span class="formw" style="width: 10%; ">
<asp:linkbutton
commandname="update"
commandargument='<%# DataBinder.Eval(Container.DataItem,
"ZoneID") %>'
text="update"
runat="server"/>
</span>
<span class="formw">
Page:
<asp:textbox
Text='<%# DataBinder.Eval(Container.DataItem, "PageLevel")
%>'
size="2"
id="PageLevelTextBox"
runat="server" />
</span>
</div>
</EditItemTemplate>
user's input. I've included relevant excerpts at the end of this message. In
the UpdateCommand code, the "PageLevelTextBox" appears to be found (it isn't
returning null), but the Text property is an empty string ("").
Am I missing something really obvious?
Thanks
Colin
private void DeployList_UpdateCommand(object source,
System.Web.UI.WebControls.DataListCommandEventArgs e)
{
int PageLevel, ZoneID;
ZoneID = int.Parse(e.CommandArgument.ToString());
TextBox PageLevelTB =
(TextBox)e.Item.FindControl("PageLevelTextBox");
try
{
PageLevel = int.Parse(PageLevelTB.Text);
Distribution dist = new
Distribution(appEnv.GetConnection());
dist.InsertAtEnd(cid, ver, ZoneID, PageLevel);
DeployList.EditItemIndex = -1;
Bind();
}
catch(Exception ex)
{
Controls.Add(new LiteralControl(ex.Message));
}
}
<edititemtemplate>
<div class="row">
<span class="label" style="width: 35%; text-align: left; ">
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</span>
<span class="formw" style="width: 10%; ">
<asp:linkbutton
commandname="update"
commandargument='<%# DataBinder.Eval(Container.DataItem,
"ZoneID") %>'
text="update"
runat="server"/>
</span>
<span class="formw">
Page:
<asp:textbox
Text='<%# DataBinder.Eval(Container.DataItem, "PageLevel")
%>'
size="2"
id="PageLevelTextBox"
runat="server" />
</span>
</div>
</EditItemTemplate>