C
ChemFinder
I created a DataGrid with a templated field:
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<aspropDownList ID="ddlScreenStatus"
runat="server" Style="z-index: 100; ">
</aspropDownList>
<asp:Button ID="ButtonSet" runat="server"
Style="z-index: 102;" Text="Button" />
</ItemTemplate>
<ItemStyle Width="98px" />
</asp:TemplateField>
For the Button, I set its text and CommandArgument in the RowCreated
event handler:
protected void GVMatchingScreens_RowCreated(object sender,
GridViewRowEventArgs e)
{
.. . .
Button setStatus = map.SetStatusButton;
setStatus.Text = "SetHere";
setStatus.CommandName = "SetStatus";
setStatus.CommandArgument = e.Row.RowIndex.ToString();
}
}
}
I see on the screen, the button's text has been set to "SetHere"
When I click the button on the screen, though, and step through the
command handler,
protected void GVMatchingScreens_RowCommand(object sender,
GridViewCommandEventArgs e)
{
// Set up location we'll need for all commands
int useRow;
useRow =
MapPageRowToData((GridView)sender,Int32.Parse(e.CommandArgument.ToString()));
I get a vluhurg in e.CommandArgument.ToString(). Somehow,
e.CommandArgument, and e.CommandName are null when the row command
event is fired.
This works for a regular bound control, but not one in a TemplateField.
Anyone have any thoughts?
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<aspropDownList ID="ddlScreenStatus"
runat="server" Style="z-index: 100; ">
</aspropDownList>
<asp:Button ID="ButtonSet" runat="server"
Style="z-index: 102;" Text="Button" />
</ItemTemplate>
<ItemStyle Width="98px" />
</asp:TemplateField>
For the Button, I set its text and CommandArgument in the RowCreated
event handler:
protected void GVMatchingScreens_RowCreated(object sender,
GridViewRowEventArgs e)
{
.. . .
Button setStatus = map.SetStatusButton;
setStatus.Text = "SetHere";
setStatus.CommandName = "SetStatus";
setStatus.CommandArgument = e.Row.RowIndex.ToString();
}
}
}
I see on the screen, the button's text has been set to "SetHere"
When I click the button on the screen, though, and step through the
command handler,
protected void GVMatchingScreens_RowCommand(object sender,
GridViewCommandEventArgs e)
{
// Set up location we'll need for all commands
int useRow;
useRow =
MapPageRowToData((GridView)sender,Int32.Parse(e.CommandArgument.ToString()));
I get a vluhurg in e.CommandArgument.ToString(). Somehow,
e.CommandArgument, and e.CommandName are null when the row command
event is fired.
This works for a regular bound control, but not one in a TemplateField.
Anyone have any thoughts?