467,903 Members | 1,811 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,903 developers. It's quick & easy.

Determining hidden key values with the Repeater control

In the datagrid I would put key values (that I didnt want to display) in
columns marked not visible, in the gridview I would put them in datakeys.
Im need to apply greater control over my html, so Im using the Repeater for
the first time. Ive added a linkbutton and am looking in its ItemCommand
event. But so far Im unable to figure out how to hide a key value, and then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark
Sep 22 '07 #1
  • viewed: 4215
Share:
6 Replies
You could use hidden form field

e.g <input type="hidden" id="hdValue" runat="server" />

or just Label contro, which you set Visisble="false"

in <ItemTemplate>. Bind the value to it (with databinding expression) or set
in code with ItemDataBound. Then in ItemCommand you could get the value by
FindControling the hdValue control on the current Item.

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"SandpointGuy" <Sa**********@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
In the datagrid I would put key values (that I didnt want to display) in
columns marked not visible, in the gridview I would put them in datakeys.
Im need to apply greater control over my html, so Im using the Repeater
for
the first time. Ive added a linkbutton and am looking in its ItemCommand
event. But so far Im unable to figure out how to hide a key value, and
then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark

Sep 23 '07 #2
SandpointGuy wrote:
In the datagrid I would put key values (that I didnt want to display) in
columns marked not visible, in the gridview I would put them in datakeys.
Im need to apply greater control over my html, so Im using the Repeater for
the first time. Ive added a linkbutton and am looking in its ItemCommand
event. But so far Im unable to figure out how to hide a key value, and then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark

protected void DataList1_ItemCommand(Object sender, DataListCommandEventArgs e) // an image was clicked on
{
String key = DataList1.DataKeys[e.Item.ItemIndex].ToString();
....

}

Sep 23 '07 #3
Visible=false won't work since it won't be rendered to client in the first
place.

You can use any suitable control as long as you set css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
You could use hidden form field

e.g <input type="hidden" id="hdValue" runat="server" />

or just Label contro, which you set Visisble="false"

in <ItemTemplate>. Bind the value to it (with databinding expression) or
set in code with ItemDataBound. Then in ItemCommand you could get the
value by FindControling the hdValue control on the current Item.

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"SandpointGuy" <Sa**********@discussions.microsoft.comwrote in message
news:94**********************************@microsof t.com...
>In the datagrid I would put key values (that I didnt want to display) in
columns marked not visible, in the gridview I would put them in datakeys.
Im need to apply greater control over my html, so Im using the Repeater
for
the first time. Ive added a linkbutton and am looking in its ItemCommand
event. But so far Im unable to figure out how to hide a key value, and
then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark


Sep 23 '07 #4
If you use Label, then visibility doesn't matter. I pointed to using hidden
Label.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:Oy**************@TK2MSFTNGP03.phx.gbl...
Visible=false won't work since it won't be rendered to client in the first
place.

You can use any suitable control as long as you set css rule display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
>You could use hidden form field

e.g <input type="hidden" id="hdValue" runat="server" />

or just Label contro, which you set Visisble="false"

in <ItemTemplate>. Bind the value to it (with databinding expression) or
set in code with ItemDataBound. Then in ItemCommand you could get the
value by FindControling the hdValue control on the current Item.

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound
controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"SandpointGuy" <Sa**********@discussions.microsoft.comwrote in message
news:94**********************************@microso ft.com...
>>In the datagrid I would put key values (that I didnt want to display) in
columns marked not visible, in the gridview I would put them in
datakeys.
Im need to apply greater control over my html, so Im using the Repeater
for
the first time. Ive added a linkbutton and am looking in its
ItemCommand
event. But so far Im unable to figure out how to hide a key value, and
then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark



Sep 23 '07 #5
E.g I'm understanding that he needs the value in ItemCommand when
client-side visibility isn't needed for the Label. Point would be just grab
the value in ItemCommand from the Label.
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uO**************@TK2MSFTNGP04.phx.gbl...
If you use Label, then visibility doesn't matter. I pointed to using
hidden Label.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:Oy**************@TK2MSFTNGP03.phx.gbl...
>Visible=false won't work since it won't be rendered to client in the
first place.

You can use any suitable control as long as you set css rule
display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
>>You could use hidden form field

e.g <input type="hidden" id="hdValue" runat="server" />

or just Label contro, which you set Visisble="false"

in <ItemTemplate>. Bind the value to it (with databinding expression) or
set in code with ItemDataBound. Then in ItemCommand you could get the
value by FindControling the hdValue control on the current Item.

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound
controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"SandpointGuy" <Sa**********@discussions.microsoft.comwrote in message
news:94**********************************@micros oft.com...
In the datagrid I would put key values (that I didnt want to display)
in
columns marked not visible, in the gridview I would put them in
datakeys.
Im need to apply greater control over my html, so Im using the Repeater
for
the first time. Ive added a linkbutton and am looking in its
ItemCommand
event. But so far Im unable to figure out how to hide a key value, and
then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark




Sep 23 '07 #6
It is not only visibility. The fact that a control is not rendered to the
client means 2 things:

1. It is not available on client.
2. It is not available on server on postbacks since the client doesn't have
the control to send it back.

It won't be found in ItemCommand.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
E.g I'm understanding that he needs the value in ItemCommand when
client-side visibility isn't needed for the Label. Point would be just
grab the value in ItemCommand from the Label.
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uO**************@TK2MSFTNGP04.phx.gbl...
>If you use Label, then visibility doesn't matter. I pointed to using
hidden Label.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:Oy**************@TK2MSFTNGP03.phx.gbl...
>>Visible=false won't work since it won't be rendered to client in the
first place.

You can use any suitable control as long as you set css rule
display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Teemu Keiski" <jo****@aspalliance.comwrote in message
news:uY**************@TK2MSFTNGP02.phx.gbl...
You could use hidden form field

e.g <input type="hidden" id="hdValue" runat="server" />

or just Label contro, which you set Visisble="false"

in <ItemTemplate>. Bind the value to it (with databinding expression)
or set in code with ItemDataBound. Then in ItemCommand you could get
the value by FindControling the hdValue control on the current Item.

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound
controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net

"SandpointGuy" <Sa**********@discussions.microsoft.comwrote in
message news:94**********************************@microsof t.com...
In the datagrid I would put key values (that I didnt want to display)
in
columns marked not visible, in the gridview I would put them in
datakeys.
Im need to apply greater control over my html, so Im using the
Repeater for
the first time. Ive added a linkbutton and am looking in its
ItemCommand
event. But so far Im unable to figure out how to hide a key value,
and then
determine it in ItemCommand.
Any help is greatly appreciated!
Thanks, Mark




Sep 23 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by John Haycock | last post: by
2 posts views Thread by Velislav | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.