Editing in gridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krisviswa
    New Member
    • Mar 2010
    • 6

    Editing in gridview

    Hi experts

    I have googled for tips/solutuins and failed to get a right method to implement following scenario.

    I have a gridview populated with data on page load from my sourcetable.
    Tomake it precise say I have fields Ac_Id, Ac_Name, Balance, and user_Id in my table accounts. The user_Id and Ac_Id forms the composite key.

    I have 3 rows in my table as follows

    1, Cash, 1000, ABC
    2. CITI, 8000, ABC
    3. BOA , 6000, ABC

    While editing in grid I want let user edit only the balance field if Ac_Name is Cash otherwise User can Edit both Ac_Name and Balance.

    Kris
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello krisviswa,

    Please post your code so we know what we are working with to help you out.

    Thanks,
    CroCrew~

    Comment

    • krisviswa
      New Member
      • Mar 2010
      • 6

      #3
      Dear Mr.cro

      thanks for volunteering help. I could solve the issue in row_upadating event by checking the values from edit item template text boxes and changing the textbox bind property to read only if the value is cash.
      Code:
      Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
              name = CType(GridView1.Rows(e.RowIndex).FindControl("Textbox1"), TextBox) )
              If name.Text = "Cash"  then
              name.Text="'<%#Eval("Ac_Name") %>'"
      regards and look forward for same cooperation in future issues

      thanks once again
      kris
      Last edited by Frinavale; Mar 25 '10, 06:35 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        Anytime.

        Happy coding,
        CroCrew~

        Comment

        Working...