Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET C# GridView Add Button

Posted on 2011-02-16
4
Medium Priority
?
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

722 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