•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 455,989 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,765 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 8546 | Replies: 6
![]() |
| |
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
Hi
I need to make application similar to excel sheet .like i have 4 columns where in (1 row will be static to display header)
and below 1 column will have a dropdownlist and remaining 3 columns are textboxes
user should be able to add as many rows as possible dynamically .
for ex:-if i have static label as below
ID Name Age Address
then ID will be dropdownlist,
Name,Age,Address--are textboxes .
user can add as many rows as possible.anybody please help me in this......
Naresh
I need to make application similar to excel sheet .like i have 4 columns where in (1 row will be static to display header)
and below 1 column will have a dropdownlist and remaining 3 columns are textboxes
user should be able to add as many rows as possible dynamically .
for ex:-if i have static label as below
ID Name Age Address
then ID will be dropdownlist,
Name,Age,Address--are textboxes .
user can add as many rows as possible.anybody please help me in this......
Naresh
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
You can put the controls you need in the footer row of your table:
http://aspnet.4guysfromrolla.com/articles/021203-1.aspx
http://aspnet.4guysfromrolla.com/articles/021203-1.aspx
Alex Cavnar, aka alc6379
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
You can put the controls you need in the footer row of your table:
http://aspnet.4guysfromrolla.com/articles/021203-1.aspx
hi Thanks for your reply .it seems i had not given the complete information.
in the example what you gave shows the data from sql database. and add's data to it.
but for me
1.i need to show empty row(which is 1 row). when 1 row is filled and when he press Add button.
2 Row with empty filed should be displayed.---like this it goes upto 'n rows'... this process is dynamical where later on based on number of rows(say 'n') ..i need to create ('n') number of tags in xml file (its in the middle of xml) after creation of tags i insert these data into those tags.
i hope you understood pls help me in this.
also let me know which is the right one i am new to asp.net. what i checked from net shows all example are like getting,insert,delete data from sql.
1.is that i need to create datatable and bind controls to it dynamicallly on button click?
2.is that need to be done through datagrid ?
or through any other way pls let me know.
Regards
Naresh
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
This will still do it-- that's why you put the controls in the footer row of the datagrid. That way, there will always be a new row. You could even go so far as to make an Add button that, when pressed, can display those fields.
hi thank you for your reply.
i did it with the following example.
http://www.sitepoint.com/article/net...t-datatables/2
this is what have done:-
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
Category:
Name:
Value:
UoM:<br> <br>
<asp
ropDownList id="ddlProducts" runat="server"> <asp:ListItem>Serial Information</asp:ListItem>
<asp:ListItem>Product Ratings</asp:ListItem>
<asp:ListItem>Commercial Information</asp:ListItem>
<asp:ListItem>Rating Plate</asp:ListItem>
</asp
ropDownList><asp:textbox id="txtName" runat="server" />
<asp:textbox id="TxtValue" runat="server" />
<asp:textbox id="TxtMetrics" runat="server" /><br> <br>
<asp:Button id="btnAdd" runat="server" Text="Add new Product Property"
onClick="AddToCart" /><br>
<br>
<asp:GridView ID="GridView1" runat="server" AutoGenerateDeleteButton="True"
Height="76px" Width="694px" AllowSorting="True" AutoGenerateEditButton="True" OnRowDeleting="GridView1_RowDeleting">
</asp:GridView>
<br>
<br> <br> <br><br>
<div>
</div>
</form>
</body>
</html>
----------------------------
public partial class _Default : System.Web.UI.Page
{
DataTable objDt;
DataRow objDr;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
AddProductData();
}
}
public void AddProductData()
{
objDt = new DataTable("ProductData");
objDt.Columns.Add("Category");
objDt.Columns.Add("Name");
objDt.Columns.Add("Value");
objDt.Columns.Add("UoM");
Session["Product"] = objDt;
}
protected void AddToCart(object sender, EventArgs e)
{
objDt =(DataTable) Session["Product"];
string Category = ddlProducts.SelectedItem.Text;
objDr = objDt.NewRow();
objDr["Category"] = ddlProducts.SelectedItem.Text;
objDr["Name"] = txtName.Text;
objDr["Value"] = TxtValue.Text;
objDr["UoM"] = TxtMetrics.Text;
objDt.Rows.Add(objDr);
Session["Product"] = objDt;
GridView1.DataSource = objDt;
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
objDt = (DataTable)Session["Product"];
objDr = objDt.Rows[e.RowIndex];
objDr.Delete();
Session["Product"] = objDt;
GridView1.DataSource = objDt;
GridView1.DataBind();
}
}
is that fine i dont think using session is the best solution.
if you suggest any advice pls reply to this posting so that i can mark this post as solved.
Naresh
Last edited by Nareshp_123 : Dec 10th, 2007 at 5:34 am.
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
Yeah... session doesn't really seem like such a great idea. Where is that objDt getting populated from to begin with?
I mean... unless you're saving the state in a database or something. That's the only way it would make sense to me. Perhaps that's why they're using state?
Hi objDT is datatable object
here goes the entire scenario....
if page is not postback,then i am creating a datatable with the required columns(1 dropdown,3 textboxes->4column)
and i storing it in session.-> then binding it to gridview
once the user enters the values into textboxes,dropdownlist. and click on ADD button
i am getting the stored datatable,and creating a new row with these valuesin the datatable and again passing back datatable to session object. and binding the updated datatable to gridview.
since here i dont have database to store.that is the problem for me.so,i am using datatable to store the value from user input.
then i getting the datatable for later purpose(for inserting values into xml file based on number of rows ,i am getting the count and creating 'count' number of tags in xml file and inserting these values into xml.....
everything works fine even delete function in gridview.
but i am not able to implement that functionality of edit in gridview
#region GridView RowEdit Event
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
//get datatable from session object & get the row to be edited
objDt = (DataTable)Session["Product"];
objDr = objDt.Rows[e.NewEditIndex];
////
////funtionality to edita row in gridview.
////
//Bind the datatable to gridview
GridView1.DataSource = objDt;
GridView1.DataBind();
}
it's ok since as of now this functionality is not major .if it is needed then i concentrate on this..
I hope you understood the entire scenario.if you suggest any suggestion pls let me know ......
since i want to make it stable....so that in future we should not face any problem...
thanks for your help..
Naresh
#endregion
Last edited by Nareshp_123 : Dec 11th, 2007 at 12:50 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- how to format a Datagrid ?? (C#)
- dynamic tables (ASP.NET)
- Adding a checkbox column dynamically (C#)
Other Threads in the ASP.NET Forum
- Previous Thread: Customize Native sharepoint webpart?
- Next Thread: conversion problem



Hybrid Mode