sx20200:
  Here is a short example of how I am doing it in the ItemDataBound Event
 
 
<code>
    Protected Sub GridView1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
GridView1.ItemDataBound
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
            Dim ctlID As New System.Web.UI.WebControls.Button
            ctlID = CType(e.Item.Cells(5).FindControl("btnAccept"),
System.Web.UI.WebControls.Button)
            ctlID.Text = "Acknowledge"
            ctlID.Attributes.Add("onclick", "javascript:uLOK=true;")
            ctlID = CType(e.Item.Cells(5).FindControl("btnReject"),
System.Web.UI.WebControls.Button)
            ctlID.Visible = False
        End If
    End Sub
</code>
 
This is setting the text and adding some javascript to the onclick of a
button, and it is setting the visibility of a second button to false.
 
Hope this helps.
Brett Stinson
b <blocked::mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
sx20200
Sent: Thursday, September 07, 2006 4:28 PM
To: [email protected]
Subject: [AspNet2] access to web control in the GridView



how can I access to web control in the GridView and use it's value 
in codebehind structure. I know It will be somethng like this
"GridView_name.FindControl("x_FieldName")", but I do not know where 
to put it.I especially do not know how I should declare it.
below code is my webform code.and I want to access the "text" value 
in gridview in code behind.

<asp:GridView ID="GridView1" runat="server" 
AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="text" HeaderText="text" 
SortExpression="text" />
<asp:BoundField DataField="id" HeaderText="id" 
InsertVisible="False" ReadOnly="True"
SortExpression="id" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:BConnStr %>"
SelectCommand="SELECT [text], [id] FROM 
[art]"></asp:SqlDataSource>



 


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNet2/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/AspNet2/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to