Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Button field in Gridview.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bbawa1@yahoo.com - 25 Jun 2007 18:06 GMT
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
Masudur - 25 Jun 2007 18:48 GMT
On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
> Hi,
>
[quoted text clipped - 4 lines]
>
> 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
bbawa1@yahoo.com - 25 Jun 2007 19:04 GMT
> On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
>
[quoted text clipped - 19 lines]
> 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");

       }
   }
Masudur - 25 Jun 2007 19:14 GMT
On Jun 26, 12:04 am, bba...@yahoo.com wrote:

> > On Jun 25, 11:06 pm, bba...@yahoo.com wrote:
>
[quoted text clipped - 42 lines]
>         }
>     }

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
bbawa1@yahoo.com - 25 Jun 2007 19:34 GMT
> On Jun 26, 12:04 am, bba...@yahoo.com wrote:
>
[quoted text clipped - 58 lines]
>
> - Show quoted text -

Thanks a lot It works
Raj - 25 Jun 2007 19:07 GMT
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

> Hi,
>
[quoted text clipped - 4 lines]
>
> Thanks in advance

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.