List Info

Thread: DetailsView - How does this work?




DetailsView - How does this work?
user name
2006-04-07 07:33:18
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

Looking for DotNetNuke-Install
user name
2006-04-07 07:40:52
Ladies and Gentlemen,
I am looking for the DotNetNuke-Install (not
DotNetNuke-source or
DotNetNuke.vsi). Where can I download it from? I have
searched many Open
Source Mirrors but I am hitting error 404.
Boster.

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

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

DetailsView - How does this work?
user name
2006-04-07 07:37:58
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

[1-3]

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