another easy one.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt M

    #1

    another easy one.

    I'm learning today.

    So I have a bound datagrid with edit items in it. I've read that in order
    to retrieve the values for those edit items (textboxes etc) I can only bind
    the grid when NOT postBack.

    i.e.
    private void Page_Load(objec t sender, System.EventArg s e)

    {

    if (!IsPostBack)

    {

    BindData();

    }

    }

    So my grid initially appears when I go to the page. If I hit the "edit"
    link on the grid, the page reloads and the grid doesn't show up. Now, this
    makes sense to me, but then how can I get the textbox values on the grid
    before the grid binds again.



    I'm sure this has been posted before, but I can't seem to find a relevant
    answer. Any ideas?

    (my code to get the text box values):

    dgServices.Edit ItemIndex = E.Item.ItemInde x;


    TextBox editService = (TextBox)
    dgServices.Item s[dgServices.Edit ItemIndex].Cells[1].FindControl("e dit_Servic
    e");

    Response.Write( editService .Text);

    Any help would be greatly appreciated.

    - matt -


  • Matt M

    #2
    Re: another easy one.

    ah. Solved it myself (well...with the help of
    http://aspnet.4guysfromrolla.com/art...71002-1.2.aspx)

    fyi: I made sure that the grid_Edit() binds the data

    i.e.
    private void Page_Load(objec t sender, System.EventArg s e)

    {

    if (!IsPostBack)

    {

    BindData();

    }

    }

    public void dgServices_Edit (object source,
    System.Web.UI.W ebControls.Data GridCommandEven tArgs e)

    {



    dgServices.Edit ItemIndex = e.Item.ItemInde x;

    BindData();

    }

    public void dgServices_Upda te(object sender,
    System.Web.UI.W ebControls.Data GridCommandEven tArgs E)

    {

    dgServices.Edit ItemIndex = E.Item.ItemInde x;


    TextBox firstBCTextBox = (TextBox)
    dgServices.Item s[dgServices.Edit ItemIndex].Cells[1].FindControl("e dit_Servic
    e");

    Response.Write( dgServices.Item s[dgServices.Edit ItemIndex].Cells[0].Text ) ;

    }

    "Matt M" <matt@remove_th is_core49.com> wrote in message
    news:WQa1b.8002 76$3C2.18113077 @news3.calgary. shaw.ca...[color=blue]
    > I'm learning today.
    >
    > So I have a bound datagrid with edit items in it. I've read that in order
    > to retrieve the values for those edit items (textboxes etc) I can only[/color]
    bind[color=blue]
    > the grid when NOT postBack.
    >
    > i.e.
    > private void Page_Load(objec t sender, System.EventArg s e)
    >
    > {
    >
    > if (!IsPostBack)
    >
    > {
    >
    > BindData();
    >
    > }
    >
    > }
    >
    > So my grid initially appears when I go to the page. If I hit the "edit"
    > link on the grid, the page reloads and the grid doesn't show up. Now,[/color]
    this[color=blue]
    > makes sense to me, but then how can I get the textbox values on the grid
    > before the grid binds again.
    >
    >
    >
    > I'm sure this has been posted before, but I can't seem to find a relevant
    > answer. Any ideas?
    >
    > (my code to get the text box values):
    >
    > dgServices.Edit ItemIndex = E.Item.ItemInde x;
    >
    >
    > TextBox editService = (TextBox)
    >[/color]
    dgServices.Item s[dgServices.Edit ItemIndex].Cells[1].FindControl("e dit_Servic[color=blue]
    > e");
    >
    > Response.Write( editService .Text);
    >
    > Any help would be greatly appreciated.
    >
    > - matt -
    >
    >[/color]


    Comment

    Working...