<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" class="grid" AllowSorting ="True" DataSourceID="SqlDataSource1" ForeColor="#333333" Height="22px" Width="776px" BorderWidth="1px" BorderColor="#AAAAAA" CellPadding="2" CellSpacing="2"><Columns><asp:BoundField DataField="ProductId" HeaderText="ProductId" SortExpression="ProductId" /><asp:TemplateField><ItemTemplate><span class="rate33"><asp:GridView ID="GridView7" runat="server" AllowSorting="True" AutoGenerateColumns="False" BorderColor="#AAAAAA" BorderWidth="1px" CellPadding="2" CellSpacing="2" ForeColor="#333333" Height="16px" PageSize="5" ShowHeader="False" Width="109px"><AlternatingRowStyle BackColor="White" Font-Size="8pt" ForeColor="Black" /><Columns><asp:BoundField DataField="ID" HeaderText="Id" ReadOnly="True" SortExpression="ID" /><asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /><asp:BoundField DataField="AttributeControlTypeId" HeaderText="AttributeControlTypeId" SortExpression="AttributeControlTypeId" /><asp:TemplateField><ItemTemplate><asp:DropDownList ID="DropDownList1" runat="server" Font-Bold="True" OnLoad="Button1_Click" style="height: 40px" ViewStateMode="Enabled"></asp:DropDownList><asp:Label ID="SLabel1" runat="server" Text='<%# Bind("ID") %>'></asp:Label> ........................
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim btn As DropDownList = DirectCast(sender, DropDownList)
Dim item As DataControlFieldCell = DirectCast(btn.Parent, DataControlFieldCell)
Dim ddl As DropDownList = DirectCast(item.FindControl("DropDownList1"), DropDownList)
Dim label1 As Label = DirectCast(item.FindControl("Slabel1"), Label)
end sub
Private Sub GridView1_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim GridView7 As GridView = DirectCast(e.Row.FindControl("GridView7"), GridView)
Dim s1 As String
Dim SQLstr As String
Dim sqlConn As New SqlConnection
Dim SEarchsqlConn As New SqlConnection
Dim strConn As String
Dim reader As SqlDataReader
Dim cmd As New SqlClient.SqlCommand
strConn = System.Configuration.ConfigurationManager.ConnectionStrings("JC").ConnectionString
sqlConn = New SqlConnection(strConn)
SEarchsqlConn = New SqlConnection(strConn)
cmd.Connection = sqlConn
Dim ds As New DataSet()
sqlConn.Open()
Dim productid As Integer = Convert.ToInt32(e.Row.Cells(0).Text)
SQLstr = "SELECT ........ WHERE Variant_ProductAttribute_Mapping.ProductId =" & productId
Dim adapter3 As SqlDataAdapter = New SqlDataAdapter(SQLstr, sqlConn)
adapter3.Fill(ds, "Varaints")
GridView7.DataSource = ds.Tables("Varaints")
GridView7.DataBind()
sqlConn.Close()
End If
Hi I have 2 gridview nested and Im not able to get the Slabel value? in the button1 click. appreciate any help!