473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
6 4471
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bivin | last post by:
How to get values of textboxs in a repeater control. How can i identify each textboxes in a repeater control and get the values of the textbox . Please help me. bivin
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
0
by: Jeff | last post by:
After I bind the repeater control in the form_load event, it builds multiple lines based on the number of rows in the dataset. In the repeater control, I have a textbox and a dropdown list box. ...
2
by: Kevin | last post by:
I've got a problem where I need to know the value of a hidden field inside a repeater once a button is clicked. Ths code inside my repeater looks like this: <input id="conf_num" type="hidden"...
3
by: renil | last post by:
I have a repeater control that displays info. from a datatable. Each row in the repeater has a checkbox. Also, I have a delete linkbutton outside the repeater control. What I'm trying to do when...
8
by: Alan Silver | last post by:
Hello, I have a repeater that has code like this... <ItemTemplate> <asp:CheckBox ID="chkDelete" Text="" RunAt="server"/> .... other stuff goes here </ItemTemplate> There is a button below...
0
by: sumithad | last post by:
hi all, can anyone help me in this? i had a repeater control associated with the database fields. also i had a check box control in that. if i click the checkbox i need to get all the values...
2
by: John Haycock | last post by:
Hi All I have a user control that uses a repeater to build a list of menu links: <itemtemplate> <li> <a href='news.aspx?newsID=<%# DataBinder.Eval(Container.DataItem,"newsID") %>'> <%#...
2
by: Velislav | last post by:
Hi, I have the following scenario: A data-bound repeater, in which every item registers a hidden field with the item's associated ID (a field pulled out of the database) using the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.