Select Button In Datagrid not working (VS2003/FW1.1)

R

Richard Adams

I've got two pages, each displaying a datagrid with a Select button
column.
With one the Select command is handled in the codebehind and works
fine.

The second page is a very similar setup, but designed after upgrading
to Visual Studio 2003/Framework 1.1 Select evidently does something,
but the event handling routine in codebehind doesn't execute. I've
stripped away almost eveything on the form and even rebuilt the page
from scratch and the Select button still is not handled.

Checked document and form properties and all are identical to the
first page, except meta tags (first page still refers to being created
in VS.NET 7.0, rather than 7.1)

Any ideas why the inconsistent behavior? How to see what the browser
is attempting to send back to the server?

I'm currently residing at No. 1 Witt's End.

Richard
 
R

Richard Adams

Postback is accounted for on page_load

What's driving me nuts is I've narrowed it down to the action is being
handled, but nothing is coming out of the datagrid, see code:

Private Sub dgPatients_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
dgPatients.SelectedIndexChanged

Dim pID As String

pID = dgPatients.SelectedItem.Cells(1).Text
Response.Write(("PID=" & pID))
....

pID (yes, there is a number in the cell in the datagrid) is coming out
blank, even though I get a SelectedItem.ItemIndex in the handler.

Datagrid is as follows:

<asp:datagrid id="dgPatients" runat="server"
AutoGenerateColumns="False">
<AlternatingItemStyle
BackColor="PaleGoldenrod"></AlternatingItemStyle>
<ItemStyle BackColor="LightGoldenrodYellow"></ItemStyle>
<HeaderStyle BackColor="Tan"></HeaderStyle>
<Columns>
<asp:ButtonColumn Text="Select" ButtonType="PushButton"
CommandName="Select">
<HeaderStyle Width="60px"></HeaderStyle>
</asp:ButtonColumn>
<asp:TemplateColumn HeaderText="Patient ID">
<HeaderStyle HorizontalAlign="Center" Height="50px"
Width="85px"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:label runat="server" Width="85px" Text='<%#
DataBinder.Eval(Container, "DataItem.patient_id") %>' >
</asp:label>
</ItemTemplate>
</asp:TemplateColumn>
....
</Columns>

Keep in mind, another webform is set up identically, as near as I can
tell, and and works.


Thought for the day: "Do programmers swear more than persons of any
other occupation?"
 
R

Richard Adams

Ok, this is really starting to annoy me...

I just found my other page, the one that works, the column that works,
is one I do on-ItemDataBound to format the one column I'm using as the
key. I put an ItemDataBound into my non-working datagrid, for the
patient_id column, and suddenly I get the SelectedItem.cells(n).text

bound event handler:

Private Sub dgPatients_ItemDataBound(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgPatients.ItemDataBound
Dim sTmp As String
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Or e.Item.ItemType =
ListItemType.SelectedItem Then
sTmp = DataBinder.Eval(e.Item.DataItem, "patient_id")
e.Item.Cells(1).Text = sTmp
End If
End Sub

Without doing this I get nothing on dg.SelectedItem.cells(n).text on a
select.

I'm using asp:labels, tried
Text='<%# DataBinder.Eval(Container, "DataItem.patient_name") %>'
and
Text='<%# Container.DataItem("patient_id") %>'
but get nothing without the ItemDataBound for the desired column.
What am I doing wrong?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top