Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GridView command field not seeming to show 1

Status
Not open for further replies.

tshad

Programmer
Jul 15, 2004
386
US
I converted my DataGrid to a GridView and have most of the pieces working.

But I can't seem to get the Commandfield to work.

The grid shows the column but there is no "Edit" linkbutton as in the DataGrid.

Is there something special I need to do to get it to show that is different from the DataGrid.

Here is the GridView:
Code:
<asp:GridView visible="False" 
			border="1"		
			id="GridView1" 
			runat="server" 
			AutoGenerateColumns="False" 
			CssClass="testsDatagrid"
			gridlines="both"
			ShowFooter="true"
            OnRowCreated="GridView1_RowCreated" 
			OnRowDataBound="GridView1_RowDataBound"
            OnRowDeleting="GridView1_RowDeleting"
			OnRowCommand="DataInsert"
			onEditCommand="DataEdit"
			onCancelCommand="DataCancel"
			onUpdateCommand="DataUpdate"
			style="margin:0">
	<AlternatingRowStyle CssClass="testsDatagridAlternate"/>
	<HeaderStyle CssClass="testsDatagridHeader"/>
	<Columns>
		<asp:TemplateField HeaderText="Answer">
			<ItemTemplate>
				<asp:Label id="lblAnswer" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Answer") %>'>
				</asp:Label>
			</ItemTemplate>
			<FooterTemplate>
				<asp:TextBox id="txtAnswerFooter" columns="60" MaxLength="250" runat="server"></asp:TextBox>
			</FooterTemplate>
			<EditItemTemplate>
				<asp:textbox id="txtAnswer"  columns="60" MaxLength="250" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Answer") %>'>
				</asp:textbox>
			</EditItemTemplate>
		</asp:TemplateField>
		<asp:TemplateField visible="false">
			<ItemTemplate>
				<asp:Label id="lblQuestionUnique" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.QuestionUnique") %>'>
				</asp:Label>
			</ItemTemplate>
			<FooterTemplate>
				<asp:Label id="lblQuestionUniqueFooter" runat="server">
				</asp:Label>
			</FooterTemplate>
		</asp:TemplateField>
		<asp:TemplateField ItemStyle-Width="100%" visible="false">
			<ItemTemplate>
				<asp:Label id="lblAnswerUnique" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.AnswerUnique") %>'>
				</asp:Label>
			</ItemTemplate>
			<FooterTemplate>
				<asp:Label id="lblAnswerUniqueFooter" runat="server">
				</asp:Label>
			</FooterTemplate>
		</asp:TemplateField>
        <asp:TemplateField ItemStyle-Width="10%" ItemStyle-HorizontalAlign="center">
            <ItemTemplate>
                <asp:Radiobutton ID="myRadioButton" AutoPostBack="True" GroupName="tom" OnCheckedChanged="MyRadioButton1_CheckedChanged" runat="server"/>
                <asp:CheckBox ID="myCheckBox" AutoPostBack="True" GroupName="tom" OnCheckedChanged="MyRadioButton1_CheckedChanged" runat="server"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField EditText="Edit"  visible="true" itemstyle-width="10%" 
			ButtonType="Link" UpdateText="Update" CancelText="Cancel" />            
		<asp:TemplateField ItemStyle-Width="45" FooterStyle-Width="45">
			<ItemTemplate>
				<asp:LinkButton CommandName="Delete" CommandArgument='<%# Container.DataItemIndex %>' Text="Delete" ID="btnDelete" Runat="server" />
			</ItemTemplate>
			<FooterTemplate>
				<asp:LinkButton CommandName="Insert" CommandArgument='<%# Container.DataItemIndex %>' Text="Add" ID="btnAdd" Runat="server" />
			</FooterTemplate>
		</asp:TemplateField >
		<asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="center" ItemStyle-Width="45">
			<itemtemplate>
				<asp:radioButton CommandName="Move" ID="rowSelected" autopostback="true" OnCheckedChanged="SetMoveGrid_Click" runat="server" />            
			</itemtemplate>
		</asp:TemplateField>
	</Columns>
</asp:GridView>

Thanks,

Tom
 
Add this to your columns collection:
Code:
<asp:CommandField ShowEditButton="True" />
 
I'll take a look at that when I get home.

Thanks,

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top