473,386 Members | 1,715 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,386 software developers and data experts.

Button field in Gridview.

Hi,

I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.

How can I do that.

Thanks in advance

Jun 25 '07 #1
5 32140
On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
Hi,

I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.

How can I do that.

Thanks in advance
Hi...

Option one on item data bound add a onclick attribute to the button
and in onclick javascript function
just use javascript to open new window... or do what ever you like...

option two ... on itemcommad grap the id of the row... and do a
page.registerstartupscript to inject a javascript which will
open a new window... or perhaps redirect

Thanks
Masudur
http://munnacs.110mb.com

Jun 25 '07 #2
On Jun 25, 10:48 am, Masudur <munn...@gmail.comwrote:
On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
Hi,
I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.
How can I do that.
Thanks in advance

Hi...

Option one on item data bound add a onclick attribute to the button
and in onclick javascript function
just use javascript to open new window... or do what ever you like...

option two ... on itemcommad grap the id of the row... and do a
page.registerstartupscript to inject a javascript which will
open a new window... or perhaps redirect

Thanks
Masudurhttp://munnacs.110mb.com
I am doing like this but it doesn't work. It is givinf me Text of
button control ""

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "redirect")
{

// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);

// Get the Text of the ID button control

string id2 = GridView1.Rows[index].Cells[2].Text;
Session["TCKid"] = id2;
Response.Redirect("tickets_View.aspx");

}
}

Jun 25 '07 #3
It fairlY simple job...the GridView control has a RowEditing event...when the
user clicks on the Edit button this event is fired.

Select the GridControl in the PropertY window in Event list double-click on
the "RowEditng" a method will be created in code behind file....

void GridView_RowEditing(Object sender, GridViewEditEventArgs e)
{

// Get the ID for the row being edited. For this example, the
// ID is contained in the first column (index 0).
String country = GridView.Rows[e.NewEditIndex].Cells[0].Text;
}

Hope this helps

~ Raj

"bb****@yahoo.com" wrote:
Hi,

I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.

How can I do that.

Thanks in advance

Jun 25 '07 #4
On Jun 26, 12:04 am, bba...@yahoo.com wrote:
On Jun 25, 10:48 am, Masudur <munn...@gmail.comwrote:
On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
Hi,
I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.
How can I do that.
Thanks in advance
Hi...
Option one on item data bound add a onclick attribute to the button
and in onclick javascript function
just use javascript to open new window... or do what ever you like...
option two ... on itemcommad grap the id of the row... and do a
page.registerstartupscript to inject a javascript which will
open a new window... or perhaps redirect
Thanks
Masudurhttp://munnacs.110mb.com

I am doing like this but it doesn't work. It is givinf me Text of
button control ""

protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "redirect")
{

// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);

// Get the Text of the ID button control

string id2 = GridView1.Rows[index].Cells[2].Text;
Session["TCKid"] = id2;

Response.Redirect("tickets_View.aspx");

}
}
hi....
do assign datakey.... field
and in row command access the datakey in following way...
GridView1.DataKeys[index].Value

or in item databound add a attribute to the button assigning the id...
buttonselect.attribute.add("dataid", 23) where 23 is your
itemdatabound's dataid...

thanks
masudur
http://munnacs.110mb.com

Jun 25 '07 #5
On Jun 25, 11:14 am, Masudur <munn...@gmail.comwrote:
On Jun 26, 12:04 am, bba...@yahoo.com wrote:


On Jun 25, 10:48 am, Masudur <munn...@gmail.comwrote:
On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
Hi,
I have a button field in GridView. It shows the ID. When I click on
it should grab the id and open new ASpx page based on that ID.
How can I do that.
Thanks in advance
Hi...
Option one on item data bound add a onclick attribute to the button
and in onclick javascript function
just use javascript to open new window... or do what ever you like...
option two ... on itemcommad grap the id of the row... and do a
page.registerstartupscript to inject a javascript which will
open a new window... or perhaps redirect
Thanks
Masudurhttp://munnacs.110mb.com
I am doing like this but it doesn't work. It is givinf me Text of
button control ""
protected void GridView1_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "redirect")
{
// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);
// Get the Text of the ID button control
string id2 = GridView1.Rows[index].Cells[2].Text;
Session["TCKid"] = id2;
Response.Redirect("tickets_View.aspx");
}
}

hi....
do assign datakey.... field
and in row command access the datakey in following way...
GridView1.DataKeys[index].Value

or in item databound add a attribute to the button assigning the id...
buttonselect.attribute.add("dataid", 23) where 23 is your
itemdatabound's dataid...

thanks
masudurhttp://munnacs.110mb.com- Hide quoted text -

- Show quoted text -
Thanks a lot It works

Jun 25 '07 #6

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

Similar topics

3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
2
by: Jasmine | last post by:
Hi, how can I set up the javascript for the button field in the grid view, so that when the user click the button, a pop up window will be opened, I mean where could I add the "window.open "url"...
0
by: shapper | last post by:
Hello, I added, at runtime, a button field of type link to a gridview. Now I need url of that button, when pressed, to be as follows: "news.aspx?id=" & channel "Channel" is the first...
1
by: JB | last post by:
I'm dynamically creating a Gridview object and filling it with contents from an ArrayList as follows: GridView2.AutoGenerateColumns = true; GridView2.DataSource = ArrayListObject;...
1
by: mbharathiraja | last post by:
I am doing a shopping cart in asp.net I am using a gridview.when a user checks the rows of grid view it should get selected. now, through a button(OUTSIDE Gridview),I should be able to...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
1
by: sejal17 | last post by:
Hello everyone, I have a problem with taking button in gridview and datalist.In datalist,i have one field to display naming card_price and one button naming BUY.I want to click that BUY...
4
pbala
by: pbala | last post by:
I created one button field in Gridview in asp.net 3.5. I wish to send mails using the button bound with ("mailid"). How can i write the code for button? Thanks in advance
4
by: bala venkata siva ram kum | last post by:
Hi friends, I need to get confirm message box while clicking delete button of gridview.please tell me the solution.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.