Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
I have 3 asp.net dropdownlist and 1 Button

dropdownlist1=(project number)

dropdownlist2=(project title)

dropdownlist3=(activity)

button =(add)

(for your info : I call the value of dropdown from list in Sharepoint2010)

I selected project number,
then I select title then activity...
press add button then all value displayed in gridview.


The problem is ,when data was insert to gridview row, it will stretch the gridview down not in html table row by row.
 
How to inserted it row by row in html table?
Posted 11-Dec-12 15:15pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I think the cleanest way to do this would be to click on the include in a Temporary table and then climb her data to the Grid
  Permalink  
Comments
man_alansik at 12-Dec-12 20:18pm
   
sorry ... cann you explain more ...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Here I have Developed following code
        static DataTable dt; 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dt = new DataTable();
                dt.Columns.Add("Project Number");
                dt.Columns.Add("Title");
                dt.Columns.Add("Activity");
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
       
        protected void Button1_Click(object sender, EventArgs e)
        {
            DataRow dr = dt.NewRow();
            dr[0] =  DropDownList1.SelectedValue;
            dr[1] =  DropDownList2.SelectedValue;
            dr[2] =  DropDownList3.SelectedValue;
            dt.Rows.Add(dr);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
 
I hope this will be helpful to you
  Permalink  
Comments
man_alansik at 12-Dec-12 3:09am
   
thank for the solution...
but let say I have html table.
three column
 
| project no | ctr no | activity |
|=dropdown= |=dropdown= | =dropdown=| add button
| -here- | -here- | -here- |
 

and how to make sure when we add the row , the new row is fill in the html table(-here-).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
man_alansik at 12-Dec-12 3:09am
   
thanks
man_alansik at 12-Dec-12 3:15am
   
thank for the solution...
but let say I have html table.
three column
 
| project no | ctr no | activity |
|=dropdown= |=dropdown= | =dropdown=| add button
| -here- | -here- | -here- |
 

and how to make sure when we add the row , the new row is fill in the html table(-here-).
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Follow this example:
 
Protected Sub btnSaveEmail_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSaveEmail.Click
        dt_email = Session("dt_email") 'OR Dim dt_email As New DataTable

        Dim dr As DataRow
        dr = dt_email.NewRow()
 
        dr("intCodigoClienteEmail") = Cint(DropDownList.Selectedvalue)
        dr("intCodigoCliente") = Cint(DropDownList.Selectedvalue)
        dr("vchEmail") = Cint(DropDownList.Selectedvalue)
 
        dt_email.Rows.Add(dr)
 
        grdEmail.DataSource = dt_email
        grdEmail.DataBind()
 
        Session("dt_email") = dt_email
    End Sub
 

First you take a datatable existing OR can create a new one, then create a datatable DataRow this by adding a line as the selected values​​.
After all done, load the datatable with the datarow.
After that load the grid with datatable
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,745
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,599
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100