Button field in Gridview.

  • Thread starter Thread starter bbawa1
  • Start date Start date
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
 
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
 
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");

}
}
 
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
 
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
 
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
 
Back
Top