List Info

Thread: DetailsView - How does this work?




DetailsView - How does this work?
user name
2006-04-07 23:14:36
Does what I want but I'd like to know how it works (might
attempt to look at
the source through reflector). Does anybody know what the
usual pattern
would be for handling two links within the GridView - would
I handle the row
command and switch the commandName?

Thanks
Robert.


-----Original Message-----
From: Discussion of building .NET applications targeted for
the Web
[mailtoOTNET-WE
BDISCUSS.DEVELOP.COM] On Behalf Of Shawn Wildermuth
Sent: Friday, April 07, 2006 5:38 PM
To: DOTNET-WEBDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-WEB] DetailsView - How does this work?

It's magically, but I have to say unless it works *EXACTLY*
like you want,
you'll end up using the FormView to get what you really
want to work.




Thanks,

Shawn Wildermuth
http://adoguy.com
C# MVP, MCSD.NET, Author and Speaker


-----Original Message-----
From: Discussion of building .NET applications targeted for
the Web
[mailtoOTNET-WE
BDISCUSS.DEVELOP.COM] On Behalf Of Robert Rolls
Sent: Friday, April 07, 2006 3:33 AM
To: DOTNET-WEBDISCUSS.DEVELOP.COM
Subject: [DOTNET-WEB] DetailsView - How does this work?

I've declared a DetailsView on my web form as follows -



<asp:GridView ID="GridView1"
runat="server" DataKeyNames="Id"
AutoGenerateColumns="False"
DataSourceID="ObjectDataSource">

<Columns>

  <asp:ButtonField CommandName="Select"
ButtonType="Link"
DataTextField="Id" />

  <asp:BoundField DataField="Surname"
HeaderText="Surname" />

  <asp:BoundField DataField="Firstname"
HeaderText="Firstname" />

  <asp:TemplateField HeaderText="Id">

    <ItemTemplate>

      <asp:LinkButton ID="LinkButton1"
Text='<%# Eval("Id") %>'
CommandName="Select" runat="server"
/>

    </ItemTemplate>

  </asp:TemplateField>

</Columns>

</asp:GridView>



<cc1:UIPObjectDataSource
ID="ObjectDataSource"
TypeName="UIPDemo.CustomerController"
runat="server"
SelectMethod="Customers"/>



I understand how the ButtonField works as the
commandArguments property is
automagically set to the bound items row. Looking at the
rendered HTML I see
for the ButtonField it has



<a id="..."
href="javascript:__doPostBack('GridView1','Select$0
)">321</a>



So I can see that the commandName is Select and the
commandArgument is the
row index.



What I can't get my head around is how the asp:LinkButton
works above the
render HTML is



<a id="..."
href="javascript:__doPostBack('GridView1$ctl03$LinkBu
tton1','')">321</a>



When I select this link within the page as expected the
SelectedIndexChanged
fires and it (confused really about now) it knows what row
to select? But I
can't see how it can calculate this given what as rendered?
Anybody got an
ideas it must something really magical or so simple I can't
see it.



Regards

Robert.





'Technical Architecture don't dwell on problems, we focus
solely on
providing solutions.'




===================================
This list is hosted by DevelopMentor.  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentor.  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )