Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: SOS: DataGrid Cell problem !!


Message #1 by "satish chandra" <sat_chand@h...> on Wed, 17 Apr 2002 10:26:33
This is a multi-part message in MIME format.

------=_NextPart_000_002D_01C1E6E1.8CCDC450
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

Try using the "OnItemDatabound" or "OnItemCreated" events to have access to
the row as soon as its created.



Here is a code-behind example :

       Public Sub CheckColumn(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
            Dim objItemType As ListItemType = CType(e.Item.ItemType,
ListItemType)
            If objItemType = ListItemType.Item Or objItemType 
ListItemType.AlternatingItem Then
                If Winner = 1 Then
                    If Int32.Parse(e.Item.Cells(2).Text) = WinningBid Then
                        e.Item.Cells(0).Text = "<img
src=""../images/price.gif"" alt=""Winner"" border=""0"">"
                    End If
                End If
            End If
        End Sub

and here is the datagrid declaration :

<asp:DataGrid Width="100%" id="BidList" CssClass="Normal"
AutoGenerateColumns="False" runat="server" HorizontalAlign="Center"
OnItemDataBound="CheckColumn">

That should work...
  -----Original Message-----
  From: adib rahman [mailto:adibrahman@h...]
  Sent: giovedì 18 aprile 2002 13.56
  To: ASPX_Professional
  Subject: [aspx_professional] RE: SOS: DataGrid Cell problem !!



  The above thing should work.Once Datagrid is created and bound we get
access of all the elements of DataGid.You also have another way as below

  Dim textbox1 As TextBox
  Dim item as DataGridItem
  item=DataGrid1.items(i)//i is the row value
  textBox1=Ctype(item.FindControl("yourTextBox"),TextBox)






  >From: "satish chandra"
  >Reply-To: "ASPX_Professional"
  >To: "ASPX_Professional"
  >Subject: [aspx_professional] RE: SOS: DataGrid Cell problem !!
  >Date: Thu, 18 Apr 2002 10:46:31
  >
  >Hi there again.. the solution does have a problem, it does not work for
  >template columns. how do i do the same for template columns. I dont want
  >to read the values form the Textboxes it opens. I want to read the values
  >before the boxes open up.
  >
  >any solutions for that ??
  >
  >thanx
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  >
  > > Try to use:
  >DataGrid1.Items[rownumber].Cells[cellnumber].Text
  >where rownumber and cellnumber start from 0
  >
  >I've been using it in my .NET application, it works fine.
  >
  >Josephine
  >
  >-----Original Message-----
  >From: satish chandra [mailto:sat_chand@h...]
  >Sent: Wednesday, 17 April 2002 8:27 PM
  >To: ASPX_Professional
  >Subject: [aspx_professional] SOS: DataGrid Cell problem !!
  >
  >
  >
  >Can anyone please tell me how to catch values from DataGrid Cells without
  >using edit boxes !!
  >
  >
  >many thanx


----------------------------------------------------------------------------
--
  Send and receive Hotmail on your mobile device: Click Here



  Return to Index