> 1)how do i add a button to a grid view (in a column of its own)?
<asp:GridView ID="MyGridView" runat="server" AutoGenerateColumns="False"
OnRowDataBound="MyGridView_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:Button ID="MyButton" runat="server">
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
> 2)how do i change the text that appeaers on the button RowCreated Event ?
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Button)e.Row.FindControl("MyButton")).Text = "Hello";
}
}
> 3)with which event can i change the text on the button when the button is
> pressed and how?
protected void MyGridView_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((Button)e.Row.FindControl("MyButton")).Attributes.Add("onclick",
"this.value='Clicked';");
}
}

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
pelegk1 - 30 Jul 2007 11:36 GMT
thnaks alot!
> > 1)how do i add a button to a grid view (in a column of its own)?
>
[quoted text clipped - 32 lines]
> }
> }
pelegk1 - 30 Jul 2007 20:32 GMT
abou the thirds Question:
how can i add a sub that wil get the click event
and get the data from : (something like:)
CType(e.Row.DataItem, Data.DataRowView)("isActive").ToString
thnaks in advance
peleg
> > 1)how do i add a button to a grid view (in a column of its own)?
>
[quoted text clipped - 32 lines]
> }
> }