Gezna
asked on
gridview reference command field in code
Hi,
For the gridview in 2.0 can someone please tell me how to reference the below <asp:commandfield> in the code behind? I can get the whole column (gvProject.columns(0)), but not each individual control per row.
Should be something like gvProject.rows(index).find control(id ) , but there is no id for this control an none can be assigned.
Anyone?
<asp:GridView onrowupdating="gvProject_R owUpdating " ID="gvProject" runat="server" AllowSorting="True" DataSourceID="ObjectDataSo urceProjec t" ForeColor="White" GridLines="None" AutoGenerateColumns="False " AllowPaging="True" Width="100%" AlternatingRowStyle-Border Style="Non e" AlternatingRowStyle-Border Color="Whi te" BorderStyle="None" BorderColor="White" EditRowStyle-BorderStyle=" None" EditRowStyle-BorderColor=" White" EmptyDataRowStyle-BorderSt yle="None" EmptyDataRowStyle-BorderCo lor="White " FooterStyle-BorderStyle="N one" FooterStyle-BorderColor="W hite" HeaderStyle-BorderStyle="N one" HeaderStyle-BorderColor="W hite" PagerStyle-BorderStyle="No ne" PagerStyle-BorderColor="Wh ite" RowStyle-BorderStyle="None " RowStyle-BorderColor="Whit e" SelectedRowStyle-BorderSty le="None" SelectedRowStyle-BorderCol or="White" >
<Columns >
<asp:CommandField buttontype="Image" ValidationGroup="UpdateGro up" ShowEditButton="True" CancelImageUrl=".\Images\P lus.gif" EditImageUrl=".\Images\Plu s.gif" UpdateImageUrl=".\Images\P lus.gif" >
<ItemStyle VerticalAlign="Top" Height="20px" />
</asp:CommandField>
For the gridview in 2.0 can someone please tell me how to reference the below <asp:commandfield> in the code behind? I can get the whole column (gvProject.columns(0)), but not each individual control per row.
Should be something like gvProject.rows(index).find
Anyone?
<asp:GridView onrowupdating="gvProject_R
<Columns >
<asp:CommandField buttontype="Image" ValidationGroup="UpdateGro
<ItemStyle VerticalAlign="Top" Height="20px" />
</asp:CommandField>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
gvProject.Rows[gvProject.S
or use template field in the columns - more flexibility
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="itemButton" runat="server" CommandName="ButtonClick" Text="Click" />
</ItemTemplate>
</asp:TemplateField>
then handle it in the rowcommand eventhandler
.....
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_Ro
public void GridView1_RowCommand(objec
{
if (e.CommandName == "ButtonClick")
{
this.TextBox1.Text = "ButtonClick";
}
}
by using templated field you can use this sort of thing
gvProject.rows(index).find