467,925 Members | 1,896 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Can't select a row in DataGrid control

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
Nov 19 '05 #1
  • viewed: 2144
Share:
3 Replies
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


"Zachary Hilbun" <gu****@vianova.com> wrote in message
news:sI****************@newssvr12.news.prodigy.com ...
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

Nov 19 '05 #2
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

"Alex Homer" <al**@stonebroom.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
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


"Zachary Hilbun" <gu****@vianova.com> wrote in message
news:sI****************@newssvr12.news.prodigy.com ...
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


Nov 19 '05 #3
You can use checkbox in each of the row for allowing users to select that
row. To knwo how to implement this in datagrid, read this article.
http://msdn.microsoft.com/library/en...ngmultiplerows
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Zachary Hilbun" <gu****@vianova.com> wrote in message
news:Wy*****************@newssvr12.news.prodigy.co m...
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

"Alex Homer" <al**@stonebroom.com> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
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


"Zachary Hilbun" <gu****@vianova.com> wrote in message
news:sI****************@newssvr12.news.prodigy.com ...
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



Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gamze | last post: by
1 post views Thread by bill yeager | last post: by
5 posts views Thread by Just Me | last post: by
reply views Thread by savvy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.