Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 771
  • Last Modified:

Using a custom edit in a gridview

I am using a gridview where it lists all of the listings by the current user. I also want to give the user the ability to edit that listing as well. I am using a link button to be able to accomplish this.

What I want the link button to do is have the user directed to another web page that will display all of the information about this particular listing and give him/her the ability to edit any particular part of that listing. Once that is complete, he/she is directed back to his "home page".

Where I am having problems is I am unable to put in the code that is necessary to accomplish this. I am hoping someone here can guide me in the right direction.
0
smitty68521
Asked:
smitty68521
  • 2
1 Solution
 
Gyanendra SinghArchitectCommented:
See for achieving your result there is 2 way
1.  you need to set the datakeynames property in yr gridview and on grdiview editing event you need to retrive datakey and pass it through querystring in another page

2. go to LINK button propeties....... (i think its Button (link type)

like ....(right click one gridview ---> smart tag----->.EDIT Coloumns---->

 editlink button properties  ( set the COMMANDNAME as Edit)

now ur code behine window

at the GRIVIEW rowcommand event

protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName == "Edit")
{

   int index = Convert.ToInt32(e.CommandArgument);
  GridView customersGridView = (GridView)e.CommandSource;

   GridViewRow row = customersGridView.Rows[index];
     response.redirect("URaspxname.aspx?querystringname1=row.Cells[urNeedCELLNO].Text.Trim()&querystingname1=row.Cells[urNeedCELLNO].Text.Trim());


}
}

0
 
smitty68521Author Commented:
This helped out a lot. Thanks for your help.
0
 
Gyanendra SinghArchitectCommented:
yr welcome
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now