Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6364535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:10:33+00:00 2026-05-25T00:10:33+00:00

i am binding the values to gridview like this <asp:GridView ID=grdViewAttachment_Client runat=server Width=615px AutoGenerateColumns=False

  • 0

i am binding the values to gridview like this

<asp:GridView ID="grdViewAttachment_Client" runat="server" Width="615px" AutoGenerateColumns="False"  GridLines="None" CssClass="grid-view" OnRowCommand="grdViewAttachment_Client_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Attachment" HeaderStyle-CssClass="hedding2">
<ItemTemplate>
<asp:LinkButton ID="lnkbtnAttachments" runat="server" Text="Delete" CommandName="Delete" CommandArgument='<%#Eval("AttachmentId") %>' ></asp:LinkButton>
</ItemTemplate>
<HeaderStyle/>
</asp:TemplateField>
<asp:TemplateField HeaderText="Attachment" HeaderStyle-CssClass="hedding2">
<ItemTemplate>
<%--<asp:LinkButton ID="lnkbtnAttachments" runat="server" Text='<%#Eval("AttachmentName") %>' CommandName='<%#Eval("AttachmentName")%>' CommandArgument='<%#Eval("AttachmentId") %>'></asp:LinkButton>--%>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%#Eval("AttachmentName") %>' CommandName='<%#Eval("AttachmentName")%>' ></asp:LinkButton>
</ItemTemplate>
<HeaderStyle/>
</asp:TemplateField>
<asp:TemplateField HeaderText="AssignedTo" HeaderStyle-CssClass="hedding2">
<ItemTemplate>
<asp:Label ID="lblAssignedTo" Text='<%#Eval("AssignedTo") %>' runat="server" CssClass="body-text"></asp:Label>
</ItemTemplate>
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField HeaderText="CreationDate" HeaderStyle-CssClass="hedding2">
<ItemTemplate>
<asp:Label ID="lblCreationDate" Text='<%#Eval("CreationDate") %>' runat="server" CssClass="body-text"></asp:Label>
 </ItemTemplate>
 <HeaderStyle />
 </asp:TemplateField>
 </Columns>
 </asp:GridView>

In my row command event i write as follows code

protected void grdViewAttachment_Client_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        SqlConnection m_Conn = new SqlConnection(Utilities.ConnectionString());
                SqlCommand m_oCmd;
        int iStID = int.Parse(e.CommandArgument.ToString());
        int pk = 0;
        int.TryParse(e.CommandArgument as string, out pk);
        string strStoreProcName = null;
        DataSet oDS1 = new DataSet();
        if (e.CommandName == "Delete")
        {
            strStoreProcName = StoredProcNames.Attachments_uspDeleteAttachs;
            m_oCmd = new SqlCommand(strStoreProcName, m_Conn);
            m_oCmd.CommandType = CommandType.StoredProcedure;
            m_oCmd.Parameters.Add("@AttachmentId", SqlDbType.Int).Value = Convert.ToInt32(e.CommandArgument.ToString());
            m_Conn.Open();
            m_oCmd.ExecuteNonQuery();
            AttachmentDetails();
        }
        string fname = e.CommandName.ToString();

    }

But i am not getting the value i am getting the exception as Input string was not in correct format can any one help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:10:34+00:00Added an answer on May 25, 2026 at 12:10 am

    es @Muhammad Akhtar was right .It should be like

    int iStID = Convert.ToInt32(gridName.DataKeys[Convert.ToInt32(e.CommandArgument.ToString())].Value);
    

    Specify Datakey property in your data grid . and you can access the data key value of the current row as above

    add datakey name to your statement

    ID_COLUMN should be a column from data table which you are binding to gridview

    Write this code for row Created

    protected void grdViewAttachment_Client_RowCreated(object sender, GridViewRowEventArgs e)
    {
    
        if (e.Row.RowType == DataControlRowType.DataRow)
        {   
            LinkButton lnkbtnAttachments=(LinkButton)e.Row.FindControl("lnkbtnAttachments");       
            lnkbtnAttachments.CommandArgument = e.Row.RowIndex.ToString();
    
            // similarly write for other controls
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i achieve something like this: <ListView Name=OverviewTitlesListView ItemsSource={Binding OverviewTitlesCollection}> <ListView.View> <GridView> <GridViewColumn
I am binding a GridView using a DataSource in asp.net, and i would like
In WPF, Can I use binding with values defined in Settings? If this is
Is there an option to hide a GridViewColumn somehow like this: <ListView.View> <GridView> <GridViewColumn
I'm binding a ddl inside a gridview inside an EditItemTemplate. The values bind but
I'm doing : <ListView Margin=34,42,42,25 Name=listView1> <ListView.View> <GridView> <GridViewColumn Width=550 Header=Value DisplayMemberBinding={Binding Path=MyValue}/> </GridView>
When Binding a GridView to a DataTable, How can we Change the value displayed
I am having a problem with binding values in my ActionScript components. I basically
I'm having problems with binding values from a view to an object. Somehow the
I use data binding to display values in text boxes in a C# Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.