Link to home
Start Free TrialLog in
Avatar of melu
melu

asked on

Using the SelectedIndexChanged Event in asp.net (vb.net)

Hi,

I am trying to use asp.net (in vb.net). I have a simple grid.
Here's the code:


<asp:datagrid id="DataGrid1" runat="server" Height="148px" Width="683px" BorderColor="Aqua"

Font-Size="Small"
                        PageSize="4" OnPageIndexChanged="DataGrid1_PageIndexChanged"

OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged"
                        AllowPaging="True" ForeColor="Blue" AutoGenerateColumns="False"

BackColor="#C0FFC0">
                        <SelectedItemStyle BackColor="#FF80FF"></SelectedItemStyle>
                        <AlternatingItemStyle Font-Size="Smaller" Font-Names="Gill Sans"

Wrap="False" BackColor="Beige"></AlternatingItemStyle>
                        <ItemStyle Font-Size="Smaller" Font-Names="Verdana"></ItemStyle>
                        <HeaderStyle Font-Names="Arial" HorizontalAlign="Left"

BackColor="LightSteelBlue"></HeaderStyle>
                        <Columns>
                              <asp:ButtonColumn CommandName="Select"

HeaderText="Ticket" DataTextField="Ticket" />
                              <asp:BoundColumn DataField="DateIn"

HeaderText="DateIn"></asp:BoundColumn>
                              <asp:BoundColumn DataField="Customer"

HeaderText="Customer"></asp:BoundColumn>
                              <asp:BoundColumn DataField="JobStatus"

HeaderText="JobStatus"></asp:BoundColumn>
                              <asp:ButtonColumn Text="Solution" ButtonType="PushButton"

HeaderText="Solution Details"></asp:ButtonColumn>
                              <asp:TemplateColumn>
                                    <HeaderStyle Width="1cm"></HeaderStyle>
                                    <HeaderTemplate>
                                          A
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                          <asp:CheckBox id=chkAssigned

runat="server" Checked='<%# DataBinder.Eval(Container.DataItem, "Assigned") %>'>
                                          </asp:CheckBox>
                                    </ItemTemplate>
                              </asp:TemplateColumn>
                        </Columns>
                        <PagerStyle Mode="NumericPages"></PagerStyle>
                  </asp:datagrid>



so basically 6 columns - where the first column is a hyperlink. I want when I click on this

hyperlink to be able to open another web page.

Therefore i have the following code:



    Public Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As

System.EventArgs) Handles DataGrid1.SelectedIndexChanged

    Dim MyClassSubRoutine As New classSubroutines()
    Dim str As String


    Dim myDataGridItem As DataGridItem
    Dim chkSelected As Button


    chkSelected = CType(DataGrid1.Items(DataGrid1.SelectedIndex).FindControl("Select"), Button)


    ' .... DO SOMETHING


End Sub


However my problem is that chkSelected doesn't get a value. Get "nothing".

I have tried to search for code sample for vb.net but no luck.

Pls help,
Rgs,

Mehul


ASKER CERTIFIED SOLUTION
Avatar of Amrik27
Amrik27
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial