Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pass ClientID in OnClientClick
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01301882
Message ID:
01302718
Vues:
26
>>int index = Convert.ToInt32(args.CommandArgument);
>
>So you're trying to set CommandArgument to some kind of integer. That wasn't clear from the code sample. What integer is supposed to be set there? The primary key of the record? What does your ASPX code look like for the link button? If the databinding code isn't working (for whatever reason), you can still use code like I posted to explicitly set it when the control is bound. Just set it to the value of the record (remember to convert it to a string).

Paul,

Originally the ASPX has ButtonField and it was not a TemplateField. This is what I currently have in ASPX for the grid:
<asp:GridView ID="grdvwUsers" runat="server" AutoGenerateColumns="False" CellPadding="4"
                                        ForeColor="#333333" GridLines="None" OnRowCommand="grdvwUsers_RowCommand" OnSelectedIndexChanged="grdvwUsers_SelectedIndexChanged" OnRowDataBound="grdvwUsers_RowDataBound">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <Columns>
                                            <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                                            <asp:TemplateField HeaderText="User Name">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label1" Text='<%# Container.DataItem.ToString() %>' runat="server"></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkbtnRemoveRole" runat="server" Text="Remove User From Role"
                                                        CommandName="RemUser" OnClick="lnkbtnRemoveRole_Click" />
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <EditRowStyle BackColor="#999999" />
                                        <SelectedRowStyle Backcolor="LightCyan" ForeColor="DarkBlue" Font-Bold="True"/>  
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:GridView>
Now, first of all, I need to be able to see the selected row differently (currently SelectedRowStyle does nothing).

Secondly, when I click the Remove User button I need to get the UserName from that row. Original code with RowCommand doesn't work anymore.

How can I get the UserName from the current Row when I'm clicking this button?

Thanks a million in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform