Wie man ein Gridview template-field wählen Sie die Zeile der Daten?

Habe ich ein Feld Befehl in einem gridview, das, wie es ist, funktioniert, wie es soll. Wenn ich wählen Sie es aus, die Zeile ist hilighted. Aber, ich brauchte, um zu konvertieren, dieses Feld in einer Vorlage, so dass ich könnte geben Sie ihm eine ID, könnte ich die Referenz bei Verwendung eines AJAX-Mobal Kontrolle. Ich Tat dies, und ich bin in der Lage zu verweisen, mit meinem Ajax control ganz gut, aber jetzt ist dieses Feld nicht markieren Sie die Zeile in der Gridview? Die Select-Wert wird benötigt für die Ajax-Steuerelement ziehen Sie die Daten-thru. Also ich denke mein Problem ist, Wie verwende ich diesen Befehl Feld als Vorlage, UND markieren Sie die Zeile? Ich hoffe ich werde erklären, mein Problem korrekt.

Hier ist das code-snippet, wenn ich es konvertieren in eine Vorlage.
Danke!

   <asp:GridView ID="GridView3" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="3" DataKeyNames="Contact_ID" DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None" PageSize="6">
         <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
             <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Select" Text="Edit"></asp:LinkButton>
                       <asp:ModalPopupExtender ID="ModalPopupExtender2" runat="server" TargetControlID="LinkButton1" PopupControlID="DetailsView1" BackgroundCssClass="modalBackground"></asp:ModalPopupExtender>
                    </ItemTemplate>
                 </asp:TemplateField>
                 <asp:BoundField DataField="Contact_ID" HeaderText="Contact_ID" InsertVisible="False" ReadOnly="True" SortExpression="Contact_ID" Visible="False" />
                 <asp:BoundField DataField="Contact_Assigned_Username" HeaderText="Username" SortExpression="Contact_Assigned_Username" />
                 <asp:BoundField DataField="Contact_First_Name" HeaderText="First Name" SortExpression="Contact_First_Name" />
                 <asp:BoundField DataField="Contact_Last_Name" HeaderText="Last Name" SortExpression="Contact_Last_Name" />
                 <asp:BoundField DataField="Contact_Email_Address" HeaderText="Email Address" SortExpression="Contact_Email_Address" />
                 <asp:BoundField DataField="Contact_Cell_Phone" HeaderText="Cell Phone" SortExpression="Contact_Cell_Phone" />
                 <asp:CheckBoxField DataField="Contact_Administrator" HeaderText="Admin" SortExpression="Contact_Administrator" />
                 <asp:CheckBoxField DataField="Contact_LineStat_Triggers_Email" HeaderText="Email Triggers" SortExpression="Contact_LineStat_Triggers_Email" />
                 <asp:CheckBoxField DataField="Contact_LineStat_Triggers_Text" HeaderText="Text Triggers" SortExpression="Contact_LineStat_Triggers_Text" />
                 <asp:CheckBoxField DataField="Contact_Web_Portal" HeaderText="Web Access" SortExpression="Contact_Web_Portal" />
                 <asp:BoundField DataField="Contact_Customer_ID" HeaderText="Contact_Customer_ID" SortExpression="Contact_Customer_ID" Visible="False" />
              </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>
  • Bitte mehr Mühe zu formatieren Sie Ihren code so, dass er lesbar ist, die nächste Zeit.
  • Tun wird. Danke
InformationsquelleAutor John | 2011-08-16
Schreibe einen Kommentar