Button field in Gridview.

B

bbawa1

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
 
M

Masudur

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
 
B

bbawa1

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");

}
}
 
G

Guest

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
 
M

Masudur

On Jun 25, 11:06 pm, (e-mail address removed) wrote:

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
 
B

bbawa1

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top