|
I made a mistake by doing a winform and not a webform You can get it in a winform but not webform.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Thanks, I have tried out, but there is no such property
|
|
|
|
|
Anuradha612 wrote: For Each ctrl In Panel1.Controls
If ctrl.ID Like "txtID" Then
'Here i should be able to refer to the control's text property
TextBox txt = (TextBox)ctrl;
Now use txt for getting the textbox properties.
|
|
|
|
|
Anuradha612 wrote: how do i retreive the text stored in text box and value selected in the combo.
Adding to Paul's post, are you getting some problem when retrieving value ? If you are not getting the value entered, check the event where you create dynamic controls. It should be before ASP.NET loads the viestate . Init would be appropriate for dynamic controls.
|
|
|
|
|
Yes, i am unable to retreive the value entered, Pls can you be more clear, with the last post, i am unable to understand,
|
|
|
|
|
This is a viewstate issue. Hope you know about viewstates . It's mechanism used to keep data across postbacks. For solving the problem, override oninit event and add your controls over there. Then ASP.NET will maintain viewstate for the control and you can get it from Controls collection.
|
|
|
|
|
Hi
You are dynamically created textbox like this.
Dim fldMetadata As TextBox<br />
fldMetadata = New TextBox<br />
fldMetadata.ID = "txtID"<br />
Panel1.Controls.Add(fldMetadata)<br />
There should be number of text box.
When u creating the control dynamically the u cannot specify same id
to all control. u have assign unique id to all textbox in page which u
create dynamically.
R u creating control dynamically in for loop?
Can u paste code here?
Regards.
Rahul
People Laugh on me Because i am Different but i Laugh on them Because they all are same.
|
|
|
|
|
rahul.net11 wrote: Can u paste code here?
He did, in his second post[^] in the thread.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Look at this example
I create two textboxes and dropdownlist on page load event.
I have one Button and one placeholder on the page.
On page load event,add all dynamically created in place holder and on button click event, I get values of the textboxes and selected value of dropdownlist.
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
CreateControls(); <br />
}<br />
public void CreateControls()<br />
{<br />
TextBox MyTxt1=new TextBox();<br />
MyTxt1.ID = "MyTxt1";<br />
TextBox MyTxt2 = new TextBox();<br />
MyTxt2.ID = "MyTxt2";<br />
DropDownList MyDDL1 = new DropDownList();<br />
MyDDL1.ID = "MyDDL1";<br />
MyDDL1.Items.Add(new ListItem("1", "1"));<br />
MyDDL1.Items.Add(new ListItem("2", "2"));<br />
DropDownList MyDDL2 = new DropDownList();<br />
MyDDL2.ID = "MyDDL2";<br />
MyDDL2.Items.Add(new ListItem("1", "1"));<br />
MyDDL2.Items.Add(new ListItem("2", "2"));<br />
<br />
PL.Controls.Add(MyTxt1);<br />
PL.Controls.Add(MyTxt2);<br />
PL.Controls.Add(MyDDL1);<br />
PL.Controls.Add(MyDDL2);<br />
<br />
}<br />
protected void MyButton_Click(object sender, EventArgs e)<br />
{<br />
string myText1 = ((TextBox)this.Page.FindControl("MyTxt1")).Text;<br />
string myText2 = ((TextBox)this.Page.FindControl("MyTxt2")).Text;<br />
string myDDL1 = ((DropDownList)this.Page.FindControl("MyDDL1")).SelectedValue;<br />
string myDDL2 = ((DropDownList)this.Page.FindControl("MyDDL2")).SelectedValue;<br />
Response.Write("Value 1 : " + myText1 + "<br />Value 2: " + myText2 + "<br />Value 3 :" + myDDL1 + "<br />Value 4: " + myDDL2);<br />
}
please don't forget to vote on the post that helped you.
|
|
|
|
|
Why the example in C#? The OP posted his code and he was doing it in VB. See his second post[^] in the thread...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
how to retrive image from database change automatically into time interval
sg
|
|
|
|
|
Rephrase your question, it makes little or no sense.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I have weird issue with nested data grids. I have a data grid with one template column. Inside template column I have another data grid. I am finding second datagrid control on first datagrids item_databound event and binding it. Everything works fine. But I have 3 hyperlink buttons in the child grid which I am not able to find out.
These are the things what I did
1 - Main grids item_databound event finding child grid and casting.
2 - Attaching item_databound event for child datagrid
3 - In child datagrids item_databound event, trying to find the hyper links like e.Item.FindControl() and cast to HyperLink type.
I am getting null reference exception in step 3. I tried iterating through the Controls collection for the Item. It is showing all the HyperLink's. But I am unable to find it and cast it. I have viewstate turned on in the page. Any idea's ?
|
|
|
|
|
Hi man,
I think you might put the event handler of child grid after binding. I have tested and it works fine..
HTML
====
<![CDATA[<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication4.WebForm1" %>]]>
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</meta></meta></meta></meta></head>
<body ms_positioning="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server">
<columns>
<asp:boundcolumn datafield="C1"></asp:boundcolumn>
<asp:boundcolumn datafield="C2"></asp:boundcolumn>
<asp:templatecolumn>
<itemtemplate>
<asp:datagrid id="DataGrid2" runat="server">
<columns>
<asp:boundcolumn datafield="C1"></asp:boundcolumn>
<asp:templatecolumn>
<itemtemplate>
<asp:hyperlink navigateurl="http://michaelsync.net" id="hypLink" runat="server">
<%# DataBinder.Eval(Container, "DataItem.C2") %>
</asp:hyperlink>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
</form>
</body>
</html>
Code-behinded file
==================
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
DataGrid1.ItemDataBound +=new DataGridItemEventHandler(DataGrid1_ItemDataBound);
DataGrid1.DataSource = getDataTable();
DataGrid1.DataBind();
}
private DataTable getDataTable()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("C1" );
dt.Columns.Add("C2");
ds.Tables.Add(dt);
for(int i=0; i<5;i++)
{
DataRow dr = dt.NewRow();
dr[0] = i.ToString();
dr[1] = "C2" + i.ToString();
dt.Rows.Add(dr);
}
return dt;
}
DataGrid dg = new DataGrid();
private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
dg = (DataGrid)e.Item.FindControl("DataGrid2");
if(dg != null)
{
dg.ItemDataBound +=new DataGridItemEventHandler(dg_ItemDataBound);
dg.DataSource = getDataTable();
dg.DataBind();
}
}
private void dg_ItemDataBound(object sender, DataGridItemEventArgs e)
{
HyperLink hlink = (HyperLink)e.Item.FindControl("hypLink");
if(hlink != null)
{
hlink.ForeColor= System.Drawing.Color.Red;
}
}
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
Michael Sync wrote: <%# DataBinder.Eval(Container, "DataItem.C2") %>
this is not like.. CP can't parse the code correctly..
<%# DataBinder.Eval(Container, "DataItem.C2") %>
|
|
|
|
|
Thanks Micheal. You won't believe, but I did the same. Still no way. Is this working at your end ?
|
|
|
|
|
N a v a n e e t h wrote: Is this working at your end ?
Yeah. I got red color on hyperlink. Can you give me your mail address? I will mail you the zip file.
|
|
|
|
|
I have emailed you. Please check that
|
|
|
|
|
How did you email me? I haven't received yet. I think CP Mail-To is not working or something.
|
|
|
|
|
Ohh you can use navaneethkn@hotmail.com. BTW, thanks for helping me.
|
|
|
|
|
I have sent it. I hope it will work at your side too. Let me know the result. I like to know this weird issue.
|
|
|
|
|
Avoid @ character delimited email addresses on public websites and discussion boards which are routinely visited and crawled by Spam Robots to harvest open and active email addresses.
Perhaps you can try the following NoSpam Workarounds:
1)navaneethkn (at) hotmail.com<br />
2) navaneethkn.nospam (at) hotmail dot com
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
hi iam using a text box when i enter something and press enter key the button click event has to work where i wrote the text enter in the text box has to be taken for this i wrote a javascrpt to handle the button clik event in textbox on key press ..the problem is that it is working in my system .but its is gettting slow in the other systems
|
|
|
|
|
jagadeeshkumar2106 wrote: but its is gettting slow in the other systems
Well, it depends on how you wrote the other system.. it's not so easy to give the correct answer to improve the performance of application.. That's why the most of companies hires the tester to test the application (including the performance issue) and the project leader or someone to review the code of the project.. because there are a lot of programmers who just want workdone and don't care about performance. Soon or later, it's gonna be huge problem..
|
|
|
|
|
It could be a wide variety of things causing your app to perform slower on other machines. Network, hardware on the other machine, etc. Cannot really tell except you should probably look for places where the code is bottlenecking.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|