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

x
?
Solved

ASP.NET C# GridView Add Button

Posted on 2011-02-16
4
Medium Priority
?
574 Views
Last Modified: 2012-05-11
I have added a button in the EditTemplate.
 
<asp:TemplateField HeaderText="Work Plan">
                    <ItemTemplate>
                        <asp:Label ID="lblJobNameCY" runat="server" Text='<%# Eval("JOB_NAME_CY") %>'></asp:Label>
                    </ItemTemplate>

                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlJobIDCY" runat="server" Text='<%# Bind("JOB_ID_CY") %>' CssClass="workPlanDropDownList"></asp:DropDownList><br />
                        <asp:Label>All</asp:Label><asp:CheckBox ID="cbxUpdateAllJobIDCY" runat="server" />
                        <asp:Button ID="btnAddJob" runat="server" Text="Add" OnClick="btnAddJob_Click"/>
                    </EditItemTemplate>
                </asp:TemplateField>

Open in new window



So it will call the function when user click it
 
protected void btnAddJob_Click(object sender, EventArgs e)
        {
            bool hasError = false;
            string three_year_work_plan_status_id = "";
            string type = "";

            string selectedCompanyID = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblCompanyID")).Text;
            string selectedDivisionID = "";
            string selectedSubDivisionID = "";

Open in new window


However, why I can't change the argument to
protected void btnAddJob_Click(object sender, GridViewUpdateEventArgs e)
so I can easily to use the variable e to access the current editing row in the GridView

anyone can help? It doesn't work....
0
Comment
Question by:mawingho
4 Comments
 
LVL 11

Accepted Solution

by:
MajorBigDeal earned 668 total points
ID: 34913841
       protected void btnAddJob_Click(object sender, EventArgs e)
        {
            Button Button1 = (Button)sender;
            GridViewRow gvRow = (GridViewRow)Button1.Parent.Parent;
           // either use the gridview row directly or take the index gvRow.RowIndex
        }

good luck
0
 
LVL 7

Assisted Solution

by:kovilpattiBalu
kovilpattiBalu earned 664 total points
ID: 34913967
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 668 total points
ID: 34914173
0
 

Author Closing Comment

by:mawingho
ID: 34923991
thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question