Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid, array, datakeyfield

Status
Not open for further replies.

DotNetGnat

Programmer
Mar 10, 2005
5,548
IN
Guys,

i am binding an array to the datagrid as shown below

Code:
string[] blah;
blah = GetMyArray();
mydg.DataSource = blah;
[red]mydg.DataKeyField = ???[/red]
mydb.DataBind();

i am not sure how to set the datakeyfield??

-DNG
 
What is the format of your array?

In order to specify a key, you will need to use a key, value pair type collection such as a hashtable.

Why are you wanting to specify the DataKeyField?

Affleck

there are 10 types of people in this world those who understand binary, and those who don't.
 
thanks for responding Affleck...

my function GetMyArray() returns a one dimensional string array which will look something like this

blah[0]= "foo"
blah[1] = "bar"
--
--
--

when it is bound to the datagrid as shown in my first post...i get the output as

Item
______
foo
bar
...

then i changed the definition of datagrid on the aspx page and created a item template and used this

<ItemTemplate>
<%# Container.DataItem %>
</ItemTemplate>

also i added another button column to my datagrid and result looked like this:

Details | list
_______________

click | foo
click | bar
...

so now when the user clicks the button "click" i want to do something specific to the selected click button and for which i was thinking of assigning the DataKeyfield...

what other alternatives do i for this??

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top