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="DataGr id1_PageIn dexChanged "
OnSelectedIndexChanged="Da taGrid1_Se lectedInde xChanged"
AllowPaging="True" ForeColor="Blue" AutoGenerateColumns="False "
BackColor="#C0FFC0">
<SelectedItemStyle BackColor="#FF80FF"></Sele ctedItemSt yle>
<AlternatingItemStyle Font-Size="Smaller" Font-Names="Gill Sans"
Wrap="False" BackColor="Beige"></Altern atingItemS tyle>
<ItemStyle Font-Size="Smaller" Font-Names="Verdana"></Ite mStyle>
<HeaderStyle Font-Names="Arial" HorizontalAlign="Left"
BackColor="LightSteelBlue" ></HeaderS tyle>
<Columns>
<asp:ButtonColumn CommandName="Select"
HeaderText="Ticket" DataTextField="Ticket" />
<asp:BoundColumn DataField="DateIn"
HeaderText="DateIn"></asp: BoundColum n>
<asp:BoundColumn DataField="Customer"
HeaderText="Customer"></as p:BoundCol umn>
<asp:BoundColumn DataField="JobStatus"
HeaderText="JobStatus"></a sp:BoundCo lumn>
<asp:ButtonColumn Text="Solution" ButtonType="PushButton"
HeaderText="Solution Details"></asp:ButtonColum n>
<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"></Page rStyle>
</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_SelectedIndexCha nged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DataGrid1.SelectedIndexCha nged
Dim MyClassSubRoutine As New classSubroutines()
Dim str As String
Dim myDataGridItem As DataGridItem
Dim chkSelected As Button
chkSelected = CType(DataGrid1.Items(Data Grid1.Sele ctedIndex) .FindContr ol("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
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="DataGr
OnSelectedIndexChanged="Da
AllowPaging="True" ForeColor="Blue" AutoGenerateColumns="False
BackColor="#C0FFC0">
<SelectedItemStyle BackColor="#FF80FF"></Sele
<AlternatingItemStyle Font-Size="Smaller" Font-Names="Gill Sans"
Wrap="False" BackColor="Beige"></Altern
<ItemStyle Font-Size="Smaller" Font-Names="Verdana"></Ite
<HeaderStyle Font-Names="Arial" HorizontalAlign="Left"
BackColor="LightSteelBlue"
<Columns>
<asp:ButtonColumn CommandName="Select"
HeaderText="Ticket" DataTextField="Ticket" />
<asp:BoundColumn DataField="DateIn"
HeaderText="DateIn"></asp:
<asp:BoundColumn DataField="Customer"
HeaderText="Customer"></as
<asp:BoundColumn DataField="JobStatus"
HeaderText="JobStatus"></a
<asp:ButtonColumn Text="Solution" ButtonType="PushButton"
HeaderText="Solution Details"></asp:ButtonColum
<asp:TemplateColumn>
<HeaderStyle Width="1cm"></HeaderStyle>
<HeaderTemplate>
A
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id=chkAssigned
runat="server" Checked='<%# DataBinder.Eval(Container.
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Mode="NumericPages"></Page
</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_SelectedIndexCha
System.EventArgs) Handles DataGrid1.SelectedIndexCha
Dim MyClassSubRoutine As New classSubroutines()
Dim str As String
Dim myDataGridItem As DataGridItem
Dim chkSelected As Button
chkSelected = CType(DataGrid1.Items(Data
' .... 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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.