Displaying data in datagrid problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Displaying data in datagrid problem

    Hi
    I am displaying data in Datagrid in ASP.NET with
    Edit/Update functionality for each row. On the same page I
    have 2 Button controls which submits the request to
    server. These button controls are Web Control & not HTML
    control. One of these buttons whose title is Delete is
    added on the aspx page in design view & also I double
    clicked on this button in design view to get the onclick
    code for this button in the code behind page. & for
    creating the other button whose title is say SaveData I
    copied the aspx syntax of the first button & also the
    code behind code for Click event of this button. I have
    taken care to give diferent id to both of these buttons.
    Now there are 2 rows displayed in the datagrid &
    both of these buttons are at the bottom. When I click on
    Delete button (one which was added in design mode)
    the request goes to the, server since there is no code
    written in the onclick event of this button page gets
    loaded with same data as it is. This is fine
    But when I click on SaveData button (one which was
    created by copying the aspx & aspx.cs code) request goes
    to the server & even though the onclink event for
    this button doesn't have any code to execute, the page
    gets loaded with disturbed datagrid structure. In the page
    the data is scattered because of uneven colspan for any
    row gets added. I tried to debug the solution , then I
    found even I am not binding any datasource in the Postback
    on onclick of savedata button the ItemCreated event of the
    datagrid gets fired which randomly sets any colspan to the
    cells which are created, because of which I gets scattered
    data when this data is rendered into the browser.
    I didn't find any reason how this should happen in
    Item created event.
    I would be thankfull if anybody could suggest me
    proper solution

    Regards
    Vinayak
    vinayak Guest

  2. Similar Questions and Discussions

    1. DataGrid not displaying data (Flex 1.5)
      DataGrid with id "stuGrid" displaying data fine but id "evtGrid" not showing . ModelLocator.MY_ARRAY.length shows correct value but DataGrid not...
    2. problem in displaying data in datagrid which is returnfrom jsp page
      :( hi all , i have one prob is that i am getting data from jsp page perfectly but when i am trying to bind them with data grid column it cant...
    3. Datagrid single data problem
      Hi, i'm doing a simple application in flex and i found a problem that i couldn't solve. I have a datagrid of information of clients, this datagrid...
    4. Displaying XML data as is with tags on the datagrid
      Hi, I want to display the XML tags (for the the XML tags is the data that is stored in a table) on the datagrid using the datasets. But since the...
    5. displaying XML data in datagrid column
      i want to display actual XML data (with tags & data) from a table's colum (XML data) in a datagrid's column... by default it shows only yhe...
  3. #2

    Default Re: Displaying data in datagrid problem

    Hi Carl
    I am binding the Dataset to datagrid in postback ==
    false. And I have implemented ItemDataBound & ItemCreated
    event. Since I am not binding data in the post back
    ItemDataBound event does not get fired but instead
    ItemCreated event get fired where it randomly puts colspan
    to a row which makes the datagrid to display data in
    disturbed manner. And this is happening only in click
    event of SaveData button & not on click on Delete button.

    Regards
    Vinayak

    >-----Original Message-----
    >Vinayak,
    >Just a guess here (since you didn't post any code).
    >
    >In the Page_Load event, do you have a "If Not
    Page.IsPostBack Then"
    >around the code where you are doing the initial data
    binding?
    >
    >Also, have you implemented any other event handlers for
    the DataGrid?
    >If so, what are you doing in those events? etc...
    >
    >Make sure you've installed the latest .NET Framework
    Service Pack
    >[url]http://msdn.microsoft.com/netframework/downloads/updates/d[/url]
    efault.aspx
    >
    >If you are still having problems, post some code which
    repros the problem.
    >
    >--
    >
    >Thanks,
    >Carl Prothman
    >Microsoft ASP.NET MVP
    >[url]http://www.able-consulting.com[/url]
    >
    >
    >"vinayak" <narvekarvinayak@hotmail.com> wrote
    >> I am displaying data in Datagrid in ASP.NET with
    >> Edit/Update functionality for each row. On the same
    page I
    >> have 2 Button controls which submits the request to
    >> server. These button controls are Web Control & not HTML
    >> control. One of these buttons whose title is Delete is
    >> added on the aspx page in design view & also I double
    >> clicked on this button in design view to get the onclick
    >> code for this button in the code behind page. & for
    >> creating the other button whose title is say SaveData I
    >> copied the aspx syntax of the first button & also the
    >> code behind code for Click event of this button. I have
    >> taken care to give diferent id to both of these buttons.
    >> Now there are 2 rows displayed in the datagrid &
    >> both of these buttons are at the bottom. When I click on
    >> Delete button (one which was added in design mode)
    >> the request goes to the, server since there is no code
    >> written in the onclick event of this button page gets
    >> loaded with same data as it is. This is fine
    >> But when I click on SaveData button (one which was
    >> created by copying the aspx & aspx.cs code) request goes
    >> to the server & even though the onclink event for
    >> this button doesn't have any code to execute, the page
    >> gets loaded with disturbed datagrid structure. In the
    page
    >> the data is scattered because of uneven colspan for any
    >> row gets added. I tried to debug the solution , then I
    >> found even I am not binding any datasource in the
    Postback
    >> on onclick of savedata button the ItemCreated event of
    the
    >> datagrid gets fired which randomly sets any colspan to
    the
    >> cells which are created, because of which I gets
    scattered
    >> data when this data is rendered into the browser.
    >> I didn't find any reason how this should happen in
    >> Item created event.
    >> I would be thankfull if anybody could suggest me
    >> proper solution
    >>
    >> Regards
    >> Vinayak
    >
    >
    >.
    >
    Vinayak Guest

  4. #3

    Default Re: Displaying data in datagrid problem

    Hi Carl
    I got the problem. Actually in ItemDataBound event I am
    modifying the Cells structure ( I am making Colspan of
    some of the rows to 3 & also deleting some columns
    according to my business functionality). This is working
    fine if I click on Delete button because on onclick of
    this button I am binding data to datagrid which makes the
    proper structuring of all the cells in ItemDatabound event
    & data is displayed properly in Datagrid. But when I click
    on SaveData button I am not binding data to datagrid which
    do not make to fire ItemDataBound event & because of which
    proper structuring of data do not take place & I get
    scattered data in datagrid.
    Now what my problem is, I thought earlier that even if
    you make changes in Cells structure of datagrid you don't
    need to bind data in postback event since viewstate will
    maintain the Cells structure & data. So it seems now that
    this statement is wrong. Can you through a light on this
    statement. I mean whether this statement is right or wrong.

    Regards
    Vinayak
    >-----Original Message-----
    >Vinayak,
    >Just a guess here (since you didn't post any code).
    >
    >In the Page_Load event, do you have a "If Not
    Page.IsPostBack Then"
    >around the code where you are doing the initial data
    binding?
    >
    >Also, have you implemented any other event handlers for
    the DataGrid?
    >If so, what are you doing in those events? etc...
    >
    >Make sure you've installed the latest .NET Framework
    Service Pack
    >[url]http://msdn.microsoft.com/netframework/downloads/updates/d[/url]
    efault.aspx
    >
    >If you are still having problems, post some code which
    repros the problem.
    >
    >--
    >
    >Thanks,
    >Carl Prothman
    >Microsoft ASP.NET MVP
    >[url]http://www.able-consulting.com[/url]
    >
    >
    >"vinayak" <narvekarvinayak@hotmail.com> wrote
    >> I am displaying data in Datagrid in ASP.NET with
    >> Edit/Update functionality for each row. On the same
    page I
    >> have 2 Button controls which submits the request to
    >> server. These button controls are Web Control & not HTML
    >> control. One of these buttons whose title is Delete is
    >> added on the aspx page in design view & also I double
    >> clicked on this button in design view to get the onclick
    >> code for this button in the code behind page. & for
    >> creating the other button whose title is say SaveData I
    >> copied the aspx syntax of the first button & also the
    >> code behind code for Click event of this button. I have
    >> taken care to give diferent id to both of these buttons.
    >> Now there are 2 rows displayed in the datagrid &
    >> both of these buttons are at the bottom. When I click on
    >> Delete button (one which was added in design mode)
    >> the request goes to the, server since there is no code
    >> written in the onclick event of this button page gets
    >> loaded with same data as it is. This is fine
    >> But when I click on SaveData button (one which was
    >> created by copying the aspx & aspx.cs code) request goes
    >> to the server & even though the onclink event for
    >> this button doesn't have any code to execute, the page
    >> gets loaded with disturbed datagrid structure. In the
    page
    >> the data is scattered because of uneven colspan for any
    >> row gets added. I tried to debug the solution , then I
    >> found even I am not binding any datasource in the
    Postback
    >> on onclick of savedata button the ItemCreated event of
    the
    >> datagrid gets fired which randomly sets any colspan to
    the
    >> cells which are created, because of which I gets
    scattered
    >> data when this data is rendered into the browser.
    >> I didn't find any reason how this should happen in
    >> Item created event.
    >> I would be thankfull if anybody could suggest me
    >> proper solution
    >>
    >> Regards
    >> Vinayak
    >
    >
    >.
    >
    Vinayak Guest

  5. #4

    Default Re: Displaying data in datagrid problem

    "Vinayak" <narvekarvinayak@hotmail.com> wrote
    > I got the problem. Actually in ItemDataBound event I am
    > modifying the Cells structure ( I am making Colspan of
    > some of the rows to 3 & also deleting some columns
    > according to my business functionality). This is working
    > fine if I click on Delete button because on onclick of
    > this button I am binding data to datagrid which makes the
    > proper structuring of all the cells in ItemDatabound event
    > & data is displayed properly in Datagrid. But when I click
    > on SaveData button I am not binding data to datagrid which
    > do not make to fire ItemDataBound event & because of which
    > proper structuring of data do not take place & I get
    > scattered data in datagrid.
    >
    Ahhh, I figured you were doing something in one of those
    DataGrid's events handlers... ;-)
    > Now what my problem is, I thought earlier that even if
    > you make changes in Cells structure of datagrid you don't
    > need to bind data in postback event since viewstate will
    > maintain the Cells structure & data. So it seems now that
    > this statement is wrong. Can you through a light on this
    > statement. I mean whether this statement is right or wrong.
    >
    Hmmm, post some same code on what you are trying to do,
    and I'll take a look to see exactly what is going on.

    --

    Thanks,
    Carl Prothman
    Microsoft ASP.NET MVP
    [url]http://www.able-consulting.com[/url]




    Carl Prothman [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139