Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
LinkButton _lnk = (LinkButton)sender;
                GridViewRow _gvr = (GridViewRow)_lnk.NamingContainer;
                int linkCount = Convert.ToInt32(_lnk);
                if (linkCount > 0.0)
                
                {

                    if (!string.IsNullOrEmpty(user))
                    {
                        _odObjs = ShiftHeadCountBL.GetEmployeeByShiftNType(_gvr.Cells[1].Text, "AB", Convert.ToDateTime(txt_Date.Text));
                    }
                    else
                    {
                        _odObjs = ShiftHeadCountBL.GetEmployeeByShiftNApproverNType(_gvr.Cells[1].Text, "AB", Convert.ToDateTime(txt_Date.Text), empCode);
                    }

                    if (_odObjs.EmpColl.Count > 0)
                    {
                        GridView1.DataSource = _odObjs.EmpColl;
                        GridView1.DataBind();
                    }
                    else
                    {
                        GridView1.DataSource = null;
                        GridView1.DataBind();
                    }
                    Pop_up.Show();


                }
                ClientScript.RegisterClientScriptBlock(Page.GetType(), "script", "alert('No recound found');", true);
            }
            catch (Exception ex)
            {
                LogService.LogInfo(ex);
            }
        }
Posted
Updated 7-Feb-14 20:14pm
v2

Obviously, It wont work . You are trying to Cast a LinkButton to an integer.

Seems that your intention was to Cast the LinkButton text value or the Gridview Row Value to integer. Change it accordingly.
 
Share this answer
 
Comments
Karthik_Mahalingam 8-Feb-14 2:14am    
yes, 5 for explaining.
JoCodes 8-Feb-14 2:20am    
Thanks :)
Member 10562086 8-Feb-14 2:24am    
i have to cast both the linkbutton text value and grid row value to integer
JoCodes 8-Feb-14 2:30am    
Check Karthik's solution ..Take the Text from linkbutton which will be a string value which you ned to convert to int.
try this
C#
int linkCount = Convert.ToInt32(_lnk.Text);
if (linkCount > 0.0)
 
Share this answer
 
Comments
JoCodes 8-Feb-14 2:18am    
5 , for the quick code resolution. :)
Karthik_Mahalingam 8-Feb-14 3:52am    
Thanks Jocodes:)
Member 10562086 8-Feb-14 2:29am    
hello karthik Sir it show input string was in not correct form error
Karthik_Mahalingam 8-Feb-14 3:53am    
make sure that the text in the button is in number format.. else it wil throw this error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900