Question : CommandArgument does not update in gridView after PostBack

Hi,

I have a gridview in an updatePanel (up1) and a search field that is out of the updatePanel.
My last column is a link button. that trigger an other updatePanel (up2) to load data for updates.
Everything works fine until I do a search.

Here is my code.

               
                   
                                                CommandArgument='<%# Bind("labelid")%>' Text='<%# Bind("labelid")%>'
                        >

                   

               


 I have used my labelid as text to see if it is updated and text show up the right id but when I click on the linkbutton, the CommandArgument didn't updates.

So it looks like it :

Before search :

| CArg. | Txt |

  1      1
  3      3
  4      4

After search

  1    31
  3    57
  4    87

Any ideas?

 
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:

        
           
           
        
 
        
        
        
        
            
            
                
                    
                        
                        
                    
                
                
                
                
                
                
                
                
                    
                        
                    
                
 
                
            
            
        
        
        
 
 
 
 
protected void gvLabel_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "editLabel")
        {
 
            action.Value = "update";
            lblMsg.Text = "";
 
            fillForm(Convert.ToInt32(e.CommandArgument));
            
            Fnc.callPanelJavascript("openPanel", "openPanel('collapsed');", upForm);
        }
    }
 
 
    protected void fillForm(int labelId)
    {
        //Génération de la grille des Dealers
        SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
        SqlCommand cmd = new SqlCommand("sel_Label", cn);
        cmd.CommandType = CommandType.StoredProcedure;
        Fnc.addSqlParameter(cmd, "rq", '%');
        Fnc.addSqlParameter(cmd, "labelid", labelId);
 
        SqlDataReader Reader;
 
        try
        {
            cn.Open();
 
            Reader = cmd.ExecuteReader();
 
            while (Reader.Read())
            {
                txtParm.Text = Reader["param"].ToString();
                txtFr.Text = Reader["French"].ToString();
                txtEn.Text = Reader["English"].ToString();
                lblMsg.Text = labelId.ToString();
            }
            Reader.Close();
            cn.Close();
 
            
 
            txtParm.Enabled = false;
 
        }
        catch (Exception err)
        {
            lblMsg.Text = Fnc.sendError(err.ToString());
        }
    }
Open in New Window Select All

Answer : CommandArgument does not update in gridView after PostBack

Thanks for clairfying.
Now I see what you are saying. Thats something weird and I tried to replicate it but could not.
I get the correct value for commandArgument.
So really not sure whats going on.
Random Solutions  
 
programming4us programming4us