Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Select Button In Datagrid not working (VS2003/FW1.1)

Reply
Thread Tools

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

 
 
Richard Adams
Guest
Posts: n/a
 
      07-17-2003
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
 
Reply With Quote
 
 
 
 
Sonali.NET[MVP]
Guest
Posts: n/a
 
      07-17-2003
Are you handling PostBack
"Richard Adams" <> wrote in message
news: ...
> 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



 
Reply With Quote
 
 
 
 
Richard Adams
Guest
Posts: n/a
 
      07-18-2003
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?"


"Sonali.NET[MVP]" <> wrote in message news:<#>...
> Are you handling PostBack
> "Richard Adams" <> wrote in message
> news: ...
> > 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

 
Reply With Quote
 
Richard Adams
Guest
Posts: n/a
 
      07-18-2003
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
select gridview row without using select button? =?Utf-8?B?RGFiYmxlcg==?= ASP .Net 5 02-27-2009 02:56 AM
DataGrid Select Button Event not fired sathya ASP .Net Datagrid Control 1 10-21-2005 03:15 PM
Submit button to select all items in a SELECT menu Gumtree Javascript 3 11-10-2004 01:45 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
implement "select all" button to select all checkboxes Matt ASP General 2 01-11-2004 01:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57