GRIDVIEW

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kabilahan
    New Member
    • May 2007
    • 14

    GRIDVIEW

    how to store gridview values in a two dimesion array

    am having a gridview like this
    [code=html]
    <asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" Width="150px">
    <Columns>
    <asp:TemplateFi eld HeaderText="tes t1">
    <ItemTemplate >
    <asp:TextBox ID="tbx1" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="tes t2">
    <ItemTemplate >
    <asp:TextBox ID="tbx2" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t3" >
    <ItemTemplate >
    <asp:TextBox ID="tbx3" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t4" >
    <ItemTemplate >
    <asp:TextBox ID="tbx4" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t5" >
    <ItemTemplate >
    <asp:TextBox ID="tbx5" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    </Columns>
    </asp:GridView>
    [/code]

    when i click a button, i want to store the datas into a two dimensional array..
    Last edited by Frinavale; Sep 19 '07, 04:33 PM. Reason: Added [code] tags to make more legible
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by kabilahan
    how to store gridview values in a two dimesion array

    am having a gridview like this
    [code=html]
    <asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" Width="150px">
    <Columns>
    <asp:TemplateFi eld HeaderText="tes t1">
    <ItemTemplate >
    <asp:TextBox ID="tbx1" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="tes t2">
    <ItemTemplate >
    <asp:TextBox ID="tbx2" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t3" >
    <ItemTemplate >
    <asp:TextBox ID="tbx3" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t4" >
    <ItemTemplate >
    <asp:TextBox ID="tbx4" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    <asp:TemplateFi eld HeaderText="t5" >
    <ItemTemplate >
    <asp:TextBox ID="tbx5" runat="server" Width="30"></asp:TextBox>
    </ItemTemplate>
    <ItemStyle Width="30px" />
    </asp:TemplateFie ld>
    </Columns>
    </asp:GridView>
    [/code]

    when i click a button, i want to store the datas into a two dimensional array..
    if you are binding your gridview with a dataset then you already have a two dimensional array (not in terms of definition) which is the Dataset.

    why do u need a 2D array..??? you can do everything,whic h you want to do with an 2D array,with a dataset .

    again if you still want to make an array then you have to loop through the records of datagrid and manually add the records to the array......

    Comment

    • kabilahan
      New Member
      • May 2007
      • 14

      #3
      Originally posted by dip_developer
      if you are binding your gridview with a dataset then you already have a two dimensional array (not in terms of definition) which is the Dataset.

      why do u need a 2D array..??? you can do everything,whic h you want to do with an 2D array,with a dataset .

      again if you still want to make an array then you have to loop through the records of datagrid and manually add the records to the array......

      am very sorry...my questino is wrong...
      actually i ve 82 textboxes...i want to store the datas into a two dimension arrray
      how to do this?

      Comment

      • dip_developer
        Recognized Expert Contributor
        • Aug 2006
        • 648

        #4
        Originally posted by kabilahan
        am very sorry...my questino is wrong...
        actually i ve 82 textboxes...i want to store the datas into a two dimension arrray
        how to do this?
        do u want to store those 82 textbox values to a 2D array??? I didnt understand..... ...

        Comment

        • kenobewan
          Recognized Expert Specialist
          • Dec 2006
          • 4871

          #5
          You started off with a gridview and now you have 82 textboxes? Sounds like this should be a different thread.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Originally posted by kenobewan
            You started off with a gridview and now you have 82 textboxes? Sounds like this should be a different thread.
            It looks like he manually populated a GridView with Textboxes.
            Not sure to what advantage a gridview has over a table (asp:table) in this situtation but regardless....

            The object "DataTable" is a very useful way to store data in "2D", you can give you columns names and add data to it from the textboxes.
            I am afraid that as far as I know you will have to loop through your textboxes to do it.

            Comment

            • kabilahan
              New Member
              • May 2007
              • 14

              #7
              Originally posted by Plater
              It looks like he manually populated a GridView with Textboxes.
              Not sure to what advantage a gridview has over a table (asp:table) in this situtation but regardless....

              The object "DataTable" is a very useful way to store data in "2D", you can give you columns names and add data to it from the textboxes.
              I am afraid that as far as I know you will have to loop through your textboxes to do it.

              am having a table with 7 Rows and 12 Columns...this table contains those textboxes. My requirement is, when the user enters all the values and clicks a button the textbox value should store in a 2d array..

              Comment

              • dip_developer
                Recognized Expert Contributor
                • Aug 2006
                • 648

                #8
                Originally posted by kabilahan
                am having a table with 7 Rows and 12 Columns...this table contains those textboxes. My requirement is, when the user enters all the values and clicks a button the textbox value should store in a 2d array..
                what will you do with this array??? I have said earlier that you can do everything with a table or dataset what you can do with an array......

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  Originally posted by kabilahan
                  am having a table with 7 Rows and 12 Columns...this table contains those textboxes. My requirement is, when the user enters all the values and clicks a button the textbox value should store in a 2d array..
                  If you cannot use the better suited objects like a DataTable, then just make a 7x12 array and loop through all your textboxes to populate it.

                  What is the problem?

                  Comment

                  Working...