Can't select a row in DataGrid control

Z

Zachary Hilbun

I'm using a DataGrid control in a web form. I can display it using binding
but when I click on any of the items there is no feedback that that row has
been selected. I changed SelectedItemStyle but the changes do not appear
when a row is clicked. What do I need to do to get it to do selection?

===================================================
Zachary Hilbun
Software Consultant http://www.vianova.com
Via Nova OpenGL, Open Inventor 3D products, Windows 95/NT
Dallas, Texas VC++, C#, embedded systems, VxD's
1977 SSII SRX31185
Glock 30
 
A

Alex Homer

Handle the ItemCommand event and set the SelectedIndex.

Includea button in your <ItemTemplate> section:
<ASP:Button CommandName="Select" Text="Info" runat="server" />

Add OnItemCommand="DoItemSelect" to your DataGrid and use an event handler
like this:

Sub DoItemSelect(objSource As Object, objArgs As DataGridCommandEventArgs)

'see if it was the Select button that was clicked
If objArgs.CommandName = "Select" Then

'set the SelectedIndex property of the list to this item's index
MyDataGrid.SelectedIndex = objArgs.Item.ItemIndex
BindDataGrid() 'bind the data and display it

End If

End Sub
 
Z

Zachary Hilbun

I've got the DataGrid working for selection but from what I can tell the
DataGrid only allows you to select 1 row at a time. Is this true? I wanted
to select several rows in some list before a postback was done. Is a
ListBox the only control I can use if I want multiple selection? Will it
require a postback for each selection?


===================================================
Zachary Hilbun
Software Consultant http://www.vianova.com
Via Nova OpenGL, Open Inventor 3D products, Windows 95/NT
Dallas, Texas VC++, C#, embedded systems, VxD's
1977 SSII SRX31185
Glock 30
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,177
Latest member
OrderGlucea
Top