CommandName and CommandArguments not persisting in TemplateField

C

ChemFinder

I created a DataGrid with a templated field:
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:DropDownList ID="ddlScreenStatus"
runat="server" Style="z-index: 100; ">
</asp:DropDownList>
<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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top