|
I want to know the code how to save data from dynamically created textboxes.
The code I have written is this in whch I have dynamically created label and textboxes in a html table.The data in the label is from a table
The code I have written so far is
public partial class _Default : System.Web.UI.Page
{
TableRow row;
TableCell cell;
Label label1;
TextBox text;
SqlConnection cnn = new SqlConnection("server=.;database=northwind;uid=sa;pwd=");
void loaddata()
{
SqlCommand cmd = new SqlCommand("select * from Categories", cnn);
SqlDataReader dr;
cnn.Open();
dr = cmd.ExecuteReader();
int i=1;
while (dr.Read())
{
row = new TableRow();
cell = new TableCell();
label1 = new Label();
label1.Text = dr["CategoryName"].ToString();
cell.Text = label1.Text;
row.Cells.Add(cell);
cell = new TableCell();
text = new TextBox();
text.ID = "text" + i;
cell.Controls.Add(text);
row.Cells.Add(cell);
Table1.Rows.Add(row);
i++;
}
cnn.Close();
dr.Close();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{ //Initiate the counter of dynamically added controls
this.NumberOfControls = 0;
}
else
{
// //Controls must be repeatedly be created on postback
this.loaddata();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= NumberOfControls; i++)
{
SqlCommand cmd = new SqlCommand("insert into DUTYDATE (DateofDuty) values(@DateofDuty)", cnn);
try
{
string name = "text" + i.ToString();
TextBox tb = Table1.FindControl(name) as TextBox;
cmd.Parameters.AddWithValue("@DateofDuty", tb.Text);
}
catch (Exception)
{
}
}
}
protected int NumberOfControls
{
get
{
return (int)ViewState["NumControls"];
}
set
{
ViewState["NumControls"] = value;
}
}
}
can anyone tell how do i save data whch the user enter at run time as this code is not running....................
|
|
|
|
|
|
savianand wrote: Subject: Please Help its urgent!!!!!!!!!!!!!!!!!!!!
Never put subject line in that way. It's not the right way to ask question. Put proper subject line, that other members can have an understanding from you subject.
savianand wrote: l how do i save data whch the user enter at run time
When ever you created the text box dynamically, you should have id . So at the time of save data , just read value from those id and save it to database.
cheers,
Abhijit
|
|
|
|
|
I asked around, and no-one else here thinks it's urgent. I guess this means you need to work in such a way that you get your help before you are in a tight jam and relying on charity to get you out.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Would u tell me how can i managed the data with primary key or Uniqe Key if i m save data in SQL Server from Windows Application but i want that if i remove data from Second Table and in 2nd Table is using Unieqe Key . if i remove a particuler ID then it Will not Remove bcz its It used in Master table and it will not remove and give Error .
so tell me how can i do this thing
i hope u understand wht i want to say ........
thanx
Naim Khan
|
|
|
|
|
hi
you have 2 solution,
1- you can set relation ship between them, and give permison to delete when primary key is deleted for table1, so table 2 will delete qutomaitcaly,
2- Or you should remove according to your relationship.
|
|
|
|
|
naim khan wrote: Subject: Hello EveryOne
This is useless. Nothing is there for giving such kind of subject line. please read forums guide lines before post.
naim khan wrote: Would u tell me how can i managed the data with primary key or Uniqe Key if i m save data in SQL Server from Windows Application but i want that if i remove data from Second Table and in 2nd Table is using Unieqe Key . if i remove a particuler ID then it Will not Remove bcz its It used in Master table and it will not remove and give Error .
Is this anything related with asp.net. This is ASP.Net , Please post it to SQL Forum.
cheers,
Abhijit
|
|
|
|
|
hi my friends,
i have html editor in asp.net(C#) webpage.
i am using iframe to get html page in another page.
is there any way to post directly html page to webpage? for example codeproject.com mesage board are using this
whenever i am writing this to you geting message directly without iframe or something else on page.
Thanks for all replying
|
|
|
|
|
cmpemikail wrote: is there any way to post directly html page to webpage?
Use a Literal control in your ASPX or ASCX file?
|
|
|
|
|
Hi All
I already Written a web service (web method) to recive sales data from various branches as XML file.
After reaching to Webmethod I am updatingthat infor to SQL server.
some times My sql server wilbe down and need to update the data once my SQL server got up.
Right now I am storing received XML's (if my sql server is down) into directory for not sending it again by branches.
need method to chek for SQL connection ... and if connection is available read the saved files and post it to Data base.. I like todo this without triggering phically. Need to run the method in time interval of every one hour to push the data to SQL.
Thanks in Advance for the help
Vas
|
|
|
|
|
Hi ALl
I have one wb based application of payroll system.I have all requirements and everything but i am weak in deasigning part.
Can u pls help me in designing like company information web form?
How it looks,how i design?
If u have any designing part,pls send me just related to this application.
Thanks
Monika
|
|
|
|
|
Monika, i suggest you to visit a free template site live
steve-templates.com and try searching for template
|
|
|
|
|
Hi to all,
I am working on a web project.The concept is based on online shopping cart.Please reply so that I can explain my problem.
thanx....
|
|
|
|
|
R1119 wrote: Please reply so that I can explain my problem.
What keeps you from explaining the problem before someone replied?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Actually I have to make a websiite which is similar to
www.eurowirecontainers.com
but i am unable to understand how to manage the database according to the user interface.
please check the above site.
|
|
|
|
|
The problem is when we click on any one item of menu,I am unable to fetch data from database.
|
|
|
|
|
Your question is too general. You have to be more specific about what the actual problem is.
To begin with, you haven't even specified which server language and which database you are using.
I could make a guess what your problem is, and write some example code for a specific language and database, using a made up database design, but what are the odds that I would even come close to anything that is remotely useful?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
How i administer the back end database tables without directly altering it using SQL commands.
Give me ideas how i do that .
or direct me in right firection any article or Page poiting to this issue .
Best regards
Rameez
|
|
|
|
|
rameez Raja wrote:
How i administer the back end database tables without directly altering it using SQL commands.
What does it mean ?
rameez Raja wrote: or direct me in right firection any article or Page poiting to this issue
What is that ?
cheers,
Abhijit
|
|
|
|
|
Not understandable.Be more specific it'll help us to answer.
Cheers!!
Brij
|
|
|
|
|
thanks for response ,
actullay i have to manage beckend database using frontend interface as user can insert, Update and delete table record using frontend easily .
here my question is that may i use Gridview control for such operations to perform easily ?
or any other control which may help me in this regard.
best Regards
Rameez
|
|
|
|
|
rameez Raja wrote: actullay i have to manage beckend database using frontend interface as user can insert, Update and delete table record using frontend easily .
Something like to manage your tables and data? If yes, for displaying data you can use GridView/DataGrid.
|
|
|
|
|
Gridview is better option
Cheers!!
Brij
|
|
|
|
|
hi,
here i am using following code to show message from server side,
result = System.Windows.Forms.MessageBox.Show("Massage detail", "MSG Title", System.Windows.Forms.MessageBoxButtons.OKCancel);
if (result == System.Windows.Forms.DialogResult.OK)
{
Response.Write("OK");
}
else { Response.Write("Cancel"); }
it works on the local host but when web host on the server it will retun error, and also try by putting system.windows.forms DLL in bin folder but not working.
if any one have solution then plz help.
-jay
modified on Monday, December 29, 2008 2:24 AM
|
|
|
|
|
why don't you use javascript confirmbox?
Cheers!!
Brij
|
|
|
|