|
hii
i have generated dynamic labels and textbox based on
the no.of rows in my table Specification.
the table contains columns:
ProductID,Specification,Value.
ProductID and Specification columns are already filled before.
i have to enter thier values on button click.
For these i have generated the respective labels and textbox
dynamically.also i have generated a button dynamically.
now on click event of this button i want that the values entered
in the textbox get submitted in the respective rows of value column in Specification table.I a have used the followin coding.plz guide
how cud i submit the values on the button click.code is:
protected void LinkButton2_Click(object sender, EventArgs e)
{
OleDbDataReader dr = null;
string str = "Select * From ProductSpecification";
OleDbCommand cmd = new OleDbCommand(str, conn);
conn.Open();
dr = cmd.ExecuteReader();
for (int i = 1; i < dr.VisibleFieldCount; i++)
{
while (dr.Read())
{
Label lbl = new Label();
String getlbl = dr["Specification"].ToString();
lbl.ID = "lbl" + getlbl;
lbl.Width=50;
Panel2.Controls.Add(lbl);
lbl.Text = getlbl;
TextBox txt = new TextBox();
string gettxt = dr["Specification"].ToString();
txt.ID = "txt" + gettxt;
Panel2.Controls.Add(txt);
Panel2.Controls.Add(new LiteralControl("<br>"));
}
}
conn.Close();
Button b = new Button();
b.Text = "AddValues";
b.Click += new EventHandler(btnadd_Click);
Panel2.Controls.Add(b);
}
thanks.....
|
|
|
|
|
mylogics wrote: now on click event of this button i want that the values entered
in the textbox get submitted in the respective rows of value column in Specification table.
If you are not creating control before Page_Load it will not able to load postback data and view state data. . You need to create all dynamic control either in init or Pre_init
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
hii m creating this dynamic controls on click event of linkbutton.
and there is no preinit event for the link button.
reply....
|
|
|
|
|
Each time the page is posted back, all the events get generated again with IsPostBack value true.
So you can check it easily.
|
|
|
|
|
mylogics wrote: preinit event for the link button
Its not LinkButton, Its Page_PreInit() ;
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
theres no page preinit event in csharp...
plz give me exact answer...
|
|
|
|
|
mylogics wrote: theres no page preinit event in csharp...
There is in .NET 3.5.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
If U cant Find Pagepreinit just paste the following code in
code file
protected void Page_PreInit(object sender, EventArgs e)
{
}
|
|
|
|
|
Well, if he 'can't find it', odds are that he's using an earlier version of .NET, and so doesn't have it at all. What you've said is not really helpful at all.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I think We Use it Page_PreInit Event even if it is older version Thts y i posted
|
|
|
|
|
sashidhar wrote: I think We Use it Page_PreInit Event even if it is older version Thts y i posted
I had already posted that it does not exist in older versions. You didn't read my response, didn't do any research and made a guess ? Fair enough then.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
|
sekannak wrote: i want to write codes are to be hify
What do you mean by that ?
sekannak wrote: can any one tell me where and which suituatuion have to be used???
When to use an Abstract Class and an Interface[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
If you have no idea why you'd use it, you probably don't need to. In any case, abstract classes have no application I can see in ASP.NET. What is hify ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: What is hify ?
I guess he wants to write some "Fundu Code".
Now boss, please don't ask me what "Fundu code" is
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
"Fundu", thats a typical Indian word which me too can't explain.
|
|
|
|
|
nagendrathecoder wrote: which me too can't explain
"Fundu " correctly pronounced "Fundoo ", which means "cool " or "awsome " only used in the Hindi language spoken in India.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Abhijit Jana wrote: Now boss, please don't ask me what "Fundu code" is
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
This is very Rude to delete your messages
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I want to use a button within a repeater. To do that I use following code, but After clicking on the button page not response.
<asp:Repeater ID="repConnections" runat="server" OnItemDataBound="repConnections_ItemDataBound">
<ItemTemplate>
<div class="friendBody">
<Kooras:ProfileDisplaySmall ShowConnectionRequestButton="false" ShowDeleteButton="true" ID="pdProfileDisplay" runat="server" />
<asp:Button ID="ConnectionDelete" runat="server" Text="Delete" onclick="ConnectionDelete_Click" />
</div>
</ItemTemplate>
</asp:Repeater>
protected void ConnectionDelete_Click(object sender, EventArgs e)
{ DeleteConnection(Convert.ToInt32(lblConnectionID1.Text));
}
Plz verify it.
shahdat
|
|
|
|
|
Your buttons need to be created BEFORE page load for viewstate to be restored and your events to fire.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
To partial update I use the repeater within a Updatepanel. Is it problem to create a button BEFORE page load?
Just now I see that button is work well without using Updatepanel. But I want to partial update the page. Plz help.
shahdat
|
|
|
|
|
MD. SHAHDAT HOSAIN wrote: Is it problem to create a button BEFORE page load?
Yes, viewstate is restored early, so your button needs to exist prior to page load, in order for viewstate to be restored.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks
Plz hear my real problem. It a big problem to me
I have a page Connection.aspx that shows all connections(friends) of a user like faecbook and plaxo.com
I need to delete a connection when the user click on delete button()
and after deleting he see his new connection list on that page.
To do this
I use a updatepanel, repeater and usercontrol(profile.ascx).
Repeater set in the updatepanel. By repeater all connection show in Connection.aspx using usercontrol(profile.ascx).
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Repeater ID="repConnections" runat="server" OnItemDataBound="repConnections_ItemDataBound">
<ItemTemplate>
<div class="friendBody">
<Kooras:ProfileDisplaySmall ShowConnectionRequestButton="false" ShowDeleteButton="true" ID="pdProfileDisplay" runat="server" />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
profile.ascx have a delete button to delete connection.
When user click on that button, connection actually deleted. but page connection.aspx not be updated.
To solve this problem I think following technique
I place a button on connection.aspx set visiable false. and after clicking on delete button of the usercontrol(profile.ascx). the button on connection.aspx will be fire.
Dear........
If this is right way , Plz tall me how can I Implement it.
shahdat
|
|
|
|