473,385 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

GridView and a button (asp.net2)

1)how do i add a button to a grid view (in a column of its own)?
2)how do i change the text that appeaers on the button RowCreated Event ?
3)with which event can i change the text on the button when the button is
pressed and how?
thnaks i nadvance
peleg
Jul 29 '07 #1
3 8266
"pelegk1" <pe*****@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
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';");
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 29 '07 #2
thnaks alot!

"Mark Rae [MVP]" wrote:
"pelegk1" <pe*****@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
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';");
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 30 '07 #3
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
"Mark Rae [MVP]" wrote:
"pelegk1" <pe*****@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
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';");
}
}
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mark Olbert | last post by:
I ran into a situation this morning where the RowUpdating event of a GridView kept insisting there were no entries in either the OldValues or NewValues dictionaries. The GridView is bound to a...
4
by: GregG | last post by:
Greetings, I have been working with the new GridView control, and while figuring out most of it's idiosyncrasies on my own, have stumbled upon a problem I cannot seem to resolve. We have...
5
by: Abhijeet Kumar | last post by:
Hi I am working with ASP.NET2.0, How can i freeze some of the columns of GridView Control. Thanks in Advance.
2
by: cartmann | last post by:
Hi, I have a gridview with a template column. In the template column i have two commandbuttons. When clicking the buttons I enter the cmd_click event - but how do I read in which row the button...
2
by: senthil22 | last post by:
hi is it possible to have right click menu on gridview in asp.net2.0 and also obtain row index on which it is right clicked for web application plz help thanks in advance senthil
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
1
by: Arunajyothi | last post by:
How to call the Activecell in gridview control in asp.net2.0
2
by: shapper | last post by:
Hello, I am working with a ListView but I suppose that with a GridView might be the same. Instead of having an Insert Button on each GridView row I would like to have only one Insert button,...
4
by: Ken Fine | last post by:
I'm making an administrative interface that lists records in a GridView. For *each* row in the gridview, I would there to be two interface elements in addition to some information associated with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.