Click here to Skip to main content
15,914,074 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionASP.NET menu 2nd level nodes selected value Pin
KUNWAR9993-Apr-12 7:18
KUNWAR9993-Apr-12 7:18 
QuestionPayment Gateway for the Middle East Pin
Jassim Rahma3-Apr-12 6:34
Jassim Rahma3-Apr-12 6:34 
Questionintegrating Paypal into ASP.NET Pin
Jassim Rahma3-Apr-12 6:33
Jassim Rahma3-Apr-12 6:33 
AnswerRe: integrating Paypal into ASP.NET Pin
jkirkerx3-Apr-12 14:05
professionaljkirkerx3-Apr-12 14:05 
GeneralRe: integrating Paypal into ASP.NET Pin
Jassim Rahma3-Apr-12 20:27
Jassim Rahma3-Apr-12 20:27 
GeneralRe: integrating Paypal into ASP.NET Pin
jkirkerx4-Apr-12 5:54
professionaljkirkerx4-Apr-12 5:54 
GeneralRe: integrating Paypal into ASP.NET Pin
Jassim Rahma15-Sep-12 8:25
Jassim Rahma15-Sep-12 8:25 
QuestionASP.net click grid view edit twice issue Pin
thepitzaboy3-Apr-12 4:40
thepitzaboy3-Apr-12 4:40 
I have a gridview created on a page where I want to provide an edit button for the user to click in. However the issue is the grid view row becomes editable only while clicking the edit button second time. Not sure what is going wrong here, any help would be appreciated.

One additional point is my grid view is displayed on the page only on a click of a button and is not there on page_load event hence.

Posting the code snippets:


ASP.NET
//MY Aspx code

<asp:GridView ID="GridView1" AllowPaging="True" BackColor="#f1f1f1" AutoGenerateColumns="false"
            Style="z-index: 101; left: 30px; position: absolute; top: 300px"
            Font-Size="Large" Font-Names="Verdana" runat="server" GridLines="None" OnRowEditing = "GridView1_RowEditing" OnRowCancelingEdit = "GridView1_CancelingEdit" OnRowUpdating = "GridView1_RowUpdating"
            BorderStyle="Outset" OnRowUpdated = "GridView1_RowUpdated" AllowSorting="false">
            <RowStyle BackColor="Gainsboro" />
            <AlternatingRowStyle BackColor="White" />
            <HeaderStyle BackColor="#0083C1" ForeColor="White" />

            <Columns>

                <asp:TemplateField HeaderText="Slice" SortExpression="name">
                    <ItemTemplate>
                        <asp:Label ID="lblslice" Text='<%# Eval("slice") %>' runat="server"></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:Label ID="lblslice" Text='<%# Eval("slice") %>' runat="server"></asp:Label>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Metric" SortExpression="Description">
                    <ItemTemplate>
                    <asp:Label ID="lblmetric" Text='<%# Eval("metric")%>' runat="server"></asp:Label>
                        </ItemTemplate>
                         <EditItemTemplate>
                    <asp:Label ID="lblmetric" Text='<%# Eval("metric")%>' runat="server"></asp:Label>
                        </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Original" SortExpression="Type">
                    <ItemTemplate>
                                            <asp:Label ID="lbloriginal" Text='<%# Eval("Original")%>' runat="server"></asp:Label>
                        </ItemTemplate>
                          <EditItemTemplate>
                                            <asp:Label ID="lbloriginal" Text='<%# Eval("Original")%>' runat="server"></asp:Label>
                        </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="WOW" SortExpression="Market">
                    <ItemTemplate>
                                            <asp:Label ID="lblwow" Text='<%# Eval("WOW")%>' runat="server"></asp:Label>

                        </ItemTemplate>
                        <EditItemTemplate>
                                            <asp:Label ID="lblwow" Text='<%# Eval("WOW")%>' runat="server"></asp:Label>

                        </EditItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="Change" SortExpression="Market" >
                    <ItemTemplate>
                    <asp:Label ID="lblChange" Text='<%# Eval("Change")%>' runat="server"></asp:Label>

                        </ItemTemplate>
                         <EditItemTemplate>
                        <asp:TextBox ID="TxtCustomerID" Text='<%# Eval("Change") %> ' runat="server"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField HeaderText="Edit" ShowEditButton="True" />

            </Columns>
        </asp:GridView>


My code behind:
C#
protected void Page_Load(object sender, EventArgs e)
{



}

public void populagridview1(string slice,string fromdate,string todate,string year)
{
    SqlCommand cmd;
    SqlDataAdapter da;
    DataSet ds;
    cmd = new SqlCommand();
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "usp_geteventchanges";
    cmd.Connection = conn;
    conn.Open();
    SqlParameter param1 = new SqlParameter("@slice", slice);
    cmd.Parameters.Add(param1);
    SqlParameter param2 = new SqlParameter("@fromdate", fromdate);
    cmd.Parameters.Add(param2);
    SqlParameter param3 = new SqlParameter("@todate", todate);
    cmd.Parameters.Add(param3);
    SqlParameter param4 = new SqlParameter("@year", year);
    cmd.Parameters.Add(param4);


    da = new SqlDataAdapter(cmd);
    ds = new DataSet();
    da.Fill(ds, "Table");
    GridView1.DataSource = ds;
    GridView1.DataBind();
    conn.Close();
}

protected void ImpactCalc(object sender, EventArgs e)
{
    populagridview1(ddl_slice.SelectedValue, dt_to_integer(Picker1.Text),        dt_to_integer(Picker2.Text), Txt_Year.Text);

}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{


    gvEditIndex = e.NewEditIndex;
    Gridview1.DataBind();


}


[My page layout]

This edit screen appears after clicking edit twice.. the grid view gets displayed on hitting the Calculate impact button. The data is from a backend stored procedure which is fired on clicking the Calculate impact button
QuestionDelete row not working Pin
byka3-Apr-12 1:49
byka3-Apr-12 1:49 
GeneralRe: Delete row not working Pin
Not Active3-Apr-12 2:09
mentorNot Active3-Apr-12 2:09 
QuestionCalling jquery method from another jquery method Pin
indian1432-Apr-12 15:08
indian1432-Apr-12 15:08 
AnswerRe: Calling jquery method from another jquery method Pin
Not Active2-Apr-12 15:57
mentorNot Active2-Apr-12 15:57 
GeneralRe: Calling jquery method from another jquery method Pin
indian1433-Apr-12 5:54
indian1433-Apr-12 5:54 
GeneralRe: Calling jquery method from another jquery method Pin
Not Active3-Apr-12 6:38
mentorNot Active3-Apr-12 6:38 
GeneralRe: Calling jquery method from another jquery method Pin
indian1433-Apr-12 6:58
indian1433-Apr-12 6:58 
AnswerRe: Calling jquery method from another jquery method Pin
jkirkerx3-Apr-12 14:21
professionaljkirkerx3-Apr-12 14:21 
AnswerRe: Calling jquery method from another jquery method Pin
jkirkerx3-May-12 9:01
professionaljkirkerx3-May-12 9:01 
QuestionHosting a WCF service in IIS 7.5 ? Pin
helloworld20202-Apr-12 13:28
helloworld20202-Apr-12 13:28 
Generalquestion???? Pin
pty311-Apr-12 22:04
pty311-Apr-12 22:04 
GeneralRe: question???? Pin
Dalek Dave1-Apr-12 22:13
professionalDalek Dave1-Apr-12 22:13 
GeneralRe: question???? Pin
Not Active2-Apr-12 1:58
mentorNot Active2-Apr-12 1:58 
GeneralRe: question???? Pin
vvashishta24-Apr-12 19:47
vvashishta24-Apr-12 19:47 
QuestionAsp.net Pin
Kalariya Bhargav1-Apr-12 19:06
Kalariya Bhargav1-Apr-12 19:06 
QuestionGridView Pin
gaurav.shukla1431-Mar-12 0:31
gaurav.shukla1431-Mar-12 0:31 
AnswerRe: GridView Pin
Gopal Rakhal31-Mar-12 16:39
Gopal Rakhal31-Mar-12 16:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.