Last post Jul 05, 2017 09:30 AM by Kelmen
Jul 04, 2017 12:10 PM|Kelmen|LINK
I'm trying to do:
in LinkButton within Item/EditItemTemplate
problem is this always yield blank.
At the event handler, e.CommandArgument is null
if I do this:
<asp:Label ID="xx" runat="server" Text='<%#Bind("Id")%>' />
I can see the Id value being rendered.
When I purposely changed the Id to a non-exist property field (eg: Id2), I will get this expected error:
This hinted the object created by EntityFramework is a DynamicProxies.
LazyLoading is already set to false, I already tried play with Configuration.ProxyCreationEnabled = false.
But I can't figure out what event I can use to include this code.
Using EnitityFramework 6.1.3, running on classical .Net 4.5.2
I also try include .AsNoTracking() in my query lamba
all doesn't work.
it's funny the itemTemplate label is working, accessing the field Id, but CommandArguement just keep yielding blank.
Jul 05, 2017 01:26 AM|Kelmen|LINK
now I can set the ProxyCreationEnabled = false, just within the entity retrieval method
DynamicProxies is no longer the cause.
but still same issue, Bind on CommandArguement yield blank value
I remove the CommandArguement Bind in the aspx markup, doing it in code at RowDataBound event, the section that I manipulate with other controls within the row:
(row.FindControl("MyLinkButton01") as LinkButton).CommandArgument = data.Id.ToString();
during debugging, it is given expected value, CommandArguement is storing what I expected
but the final render html still blank
Jul 05, 2017 03:00 AM|Kelmen|LINK
as at current troubleshooting, i believe the issue is not about the Bind, I even hardcode/fixed the value of CommandArguement
the problem is when the postback onclick being generated, it's missing the CommandArguement
Jul 05, 2017 06:38 AM|Cathy Zou|LINK
Are you solved your problem?
if not, you could try use the gridview's rowcommand event to get ur command argument for this.
void ProductsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
// If multiple buttons are used in a GridView control, use the
// CommandName property to determine which button was clicked.
int index = Convert.ToInt32(e.CommandArgument);
//do something here
After that, if you still have problem.
would your please provide us with more code so that we could reproduce your problem.
Jul 05, 2017 07:43 AM|Kelmen|LINK
I already did/tried this.
one of my earlier post about doing it in "OnDataBound", it's typo error. it is "OnRowDataBound"
funny thing is i have few other pages using this feature in similar way, but no issues with those.
I'm going to work on a custom control, whack at the onclick attribute when being render.
Jul 05, 2017 09:30 AM|Kelmen|LINK
I think i found what causing the issue.
by removing the gridview OnDataBound, it's working as expected
the codes in OnDataBound is attempt to create multiple rows of headers
the header manipulation does worked.
but for whatever reason, this seems to cause the issue i'm facing. guess whatever the base doing is kind of hardcoding something with the rows/columns