Protected Sub GridViewAll_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles GridView1.SelectedIndexChanging
GridViewAll.Rows.OfType(Of GridViewRow)().ToList().Where(Function(a) a.RowIndex <> GridViewAll.SelectedIndex).ToList().ForEach(Function(b) b.Visible = False)
End Sub
Sorry what i mean by not working is that .... with the code being there it does not perform what is intended. so pretty much its not working. here is my gridview code
Hisham.NET
Participant
1794 Points
460 Posts
Re: GridView Select
Jun 27, 2010 09:08 PM|LINK
Hi oluts ...
Try this
oluts
Member
30 Points
299 Posts
Re: GridView Select
Jun 27, 2010 09:20 PM|LINK
Thanks Again and am so sorry if it taken me so long to get this.. .i am new to ASP. i tried the code and nothing happens. this is my event handler
sansan
All-Star
53942 Points
8147 Posts
Re: GridView Select
Jun 27, 2010 09:25 PM|LINK
add that import at the beginning of the class
Imports System.Linq
and use this
Protected Sub GridViewAll_SelectedIndexChanged(ByVal sender As Object, ByVal e As System. EventArgs) Handles GridView1.SelectedIndexChanged
oluts
Member
30 Points
299 Posts
Re: GridView Select
Jun 27, 2010 09:30 PM|LINK
Hisham,
Thanks Your code did not work either. Not sure whats wrong...
sansan
All-Star
53942 Points
8147 Posts
Re: GridView Select
Jun 27, 2010 09:33 PM|LINK
can you please post the code that you have written.
oluts
Member
30 Points
299 Posts
Re: GridView Select
Jun 27, 2010 09:41 PM|LINK
Protected Sub GridViewAll_SelectedIndexChanged(ByVal sender As Object, ByVal e As System. EventArgs) Handles GridViewAll.SelectedIndexChanged
Imports System.Linq()
GridViewAll.Rows.OfType(Of GridViewRow)().ToList().Where(Function(a) a.RowIndex <> GridViewAll.SelectedIndex).ToList().ForEach(Function(b) b.Visible = False)
End Sub.
This does not work either
sansan
All-Star
53942 Points
8147 Posts
Re: GridView Select
Jun 27, 2010 09:51 PM|LINK
what do you mean by not working.
Did you set a breakpoint and see if that code is working.
what did you use for showing select button.
can you post the parent gridview code.
Thanks.
oluts
Member
30 Points
299 Posts
Re: GridView Select
Jun 27, 2010 10:32 PM|LINK
Sansan,
Sorry what i mean by not working is that .... with the code being there it does not perform what is intended. so pretty much its not working. here is my gridview code
<asp:GridView ID="GridViewAll" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="RelationshipAll" ForeColor="#333333" OnRowDeleting="GridviewAll_rowdeleting"
GridLines="None" Visible ="False" onselectedindexchanged="GridViewAll_SelectedIndexChanged" style="text-align: center; margin-bottom: 0px; margin-left: 59px;" Width="1109px" Height="215px" DataKeyNames="recordid,banknumber">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField ShowHeader="false">
<ItemTemplate>
<asp:Button ID="butEntityEdit" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" Font-Size="Smaller" Height="25px" style="font-size: x-small; font-weight: 700;" Width="50px" />
<asp:Button ID="BtnDelete" runat="server" CausesValidation="false" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Delete this record?');" Font-Size="Smaller" Height="25px" style="font-size: x-small; font-weight: 700;" Width="50px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="butEntityUpdate" runat="server" CausesValidation="True" CommandName="Update" Text="Update" ValidationGroup="ValidGrpEntityUpdt" Height="25px" Width="50px" style="font-size: x-small; font-weight: 700; color: #FF0000;" />
<asp:Button ID="butEntityCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" Height="25px" Width="50px" style="font-size: x-small; font-weight: 700; color: #FF0000;" />
</EditItemTemplate>
<HeaderTemplate>
<asp:Button ID="butAddEntity" runat="server" CommandName="Insert" Font-Size="Smaller" Height="25px" style="font-weight: 700; color: #0066FF; font-size: x-small;" Text=" Add " ValidationGroup="ValidGrpEntityAdd" Width="50px" OnClick="butAddEntity_Click"/>
<asp:Button ID="butCancel" runat="server" CausesValidation="False" CommandName="Cancel" Font-Size="Smaller" Height="25px" style="color: #000099; font-weight: 700; font-size: x-small;" Text="Return" Width="50px" />
</HeaderTemplate>
<HeaderStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="RecordId" SortExpression="RecordId" Visible="False">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("RecordId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblAcctLegalID" runat="server" Text='<%# Eval("RecordId") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BankName" InsertVisible="False" SortExpression="BankNumber" Visible="False">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("BankNumber") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblAcctID" runat="server" Text='<%# Eval("BankNumber") %>'></asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BankNum" SortExpression="BankNum">
<EditItemTemplate>
<asp:TextBox ID="TxtEditBankNum" runat="server" Enabled="False" style="font-size: small" Text='<%# Bind("BankNumber") %>' Width="100px" Wrap="False"></asp:TextBox>
</EditItemTemplate>
<HeaderTemplate >
<asp:Label ID="lblAddBankNum" runat="server" style="font-size: small; font-weight: 700; text-align: left;" Text="Bank"></asp:Label>
<br />
<asp:DropDownList ID="dropAddBankNum" runat="server" AutoPostBack="True" CssClass="style4" DataSourceID="bankcodes" DataTextField="BankDirectory" DataValueField="Bank_Number" onselectedindexchanged="gridview2_SelectedIndexChanged"
SelectedValue='<%# Bind("Bank_Number") %>' style="font-size: x-small" TabIndex="2" AppendDataBoundItems="true" Width="100px" Height="23px">
</asp:DropDownList>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblBankNum" runat="server" Text='<%# Bind("BankNumber") %>' Width="100px"></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="NoteAccountNumber" SortExpression="NoteAccountNumber">
<ItemTemplate>
<asp:Label ID="lblAcctNoteNum" runat="server" Height="17px" Text='<%# Bind("NoteAccountNumber") %>' Width="150px"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditAcctNumber" runat="server" Enabled="False" Text='<%# Bind("NoteAccountNumber") %>' Width="150px" Wrap="False"></asp:TextBox>
</EditItemTemplate>
<HeaderTemplate>
<asp:Label ID="lblAddAcctNum" runat="server" style="font-size: small; font-weight: 700; text-align: left;" Text="Account Number"></asp:Label>
<br />
<asp:DropDownList ID="dropAddAcctNumber" runat="server" CssClass="style4" DataSourceID="Riskfactordaily" DataTextField="Balanceinfo" OnDataBound ="DropAddacctnum_databound"
DataValueField="NoteAccountNumber" TabIndex="3" Width="400px" AppendDataBoundItems="true" style="font-size: x-small"
Height="23px">
</asp:DropDownList>
</HeaderTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
Hisham.NET
Participant
1794 Points
460 Posts
Re: GridView Select
Jun 27, 2010 11:15 PM|LINK
Hi again ...
Why it doesn work?!! Are you sure you 're working on ASP.NET 3.5?
about the handler automatically added whenever you clicked the GridView control.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: GridView Select
Jun 28, 2010 01:42 AM|LINK
Have you got any errors here? And you maybe post some issues of your problem or debugging information for us through images or words...
:)