Monday, March 26, 2012
populate a dg column based upon the value populated to another row in the datagrid
column based upon the value populated to another row in the datagrid?
(i.e. I have a drop down which I want to populate differently for each
row with user names based upon a UserRegionID which is also a column in
the row).
Since you don't actually know the value of the UserRegionID until the
data is already bound to the datagrid, how do you do this?
Thanks,
Mike
*** Sent via Developersdex http://www.examnotes.net ***You can use the datagrid events (RowDataBound I think) to handle this
by populating your dropdown using the id of each row as the grid is
populated
HTH
---
David Gray
ASP.NET/C# Developer/Architect (MCAD.NET)
On Fri, 13 Jan 2006 02:23:16 -0800, Mike P <mike.parr@.gmail.com>
wrote:
>Is it possible when populating a datagrid to populate a dropdownlist
>column based upon the value populated to another row in the datagrid?
>(i.e. I have a drop down which I want to populate differently for each
>row with user names based upon a UserRegionID which is also a column in
>the row).
>Since you don't actually know the value of the UserRegionID until the
>data is already bound to the datagrid, how do you do this?
>
>Thanks,
>Mike
>
>*** Sent via Developersdex http://www.examnotes.net ***
populate a dg column based upon the value populated to another row in the datagrid
column based upon the value populated to another row in the datagrid?
(i.e. I have a drop down which I want to populate differently for each
row with user names based upon a UserRegionID which is also a column in
the row).
Since you don't actually know the value of the UserRegionID until the
data is already bound to the datagrid, how do you do this?
Thanks,
Mike
*** Sent via Developersdex http://www.developersdex.com ***You can use the datagrid events (RowDataBound I think) to handle this
by populating your dropdown using the id of each row as the grid is
populated
HTH
-------------
David Gray
ASP.NET/C# Developer/Architect (MCAD.NET)
On Fri, 13 Jan 2006 02:23:16 -0800, Mike P <mike.parr@.gmail.com>
wrote:
>Is it possible when populating a datagrid to populate a dropdownlist
>column based upon the value populated to another row in the datagrid?
>(i.e. I have a drop down which I want to populate differently for each
>row with user names based upon a UserRegionID which is also a column in
>the row).
>Since you don't actually know the value of the UserRegionID until the
>data is already bound to the datagrid, how do you do this?
>
>Thanks,
>Mike
>
>*** Sent via Developersdex http://www.developersdex.com ***
Populate a DropDownList
I need to populate a dropdownlist with items form one SQL Table in SqlDataSource1 but the selected value and the data text need to match the ones that are already into another SQL Table in SqlDataSource2.
Any Sugestions?
You can manually compare the data between the tables in codebehind using the classes found in System.Data.SqlClient & System.Data.Sql. Then you can use the DropDownList.Items.Add(new ListItem()) methods to add new items to your dropdownlist.
Populate asp:label with text from db and retain formatting?
Im can't seem to figure this out OR find any documentation on if it's possib
le; I need to populate the value of an asp:label with text retrieved from th
e database. However when the text is populated I need to retain carriage ret
urns and indents that the t
ext contains. That way if I want to see this:
Some text with a manual
carriage return.
1. this is one.
2. this is two.
It doesn't look like this:
Some text with a manual carriage return. 1. this is one. 2. this is two.
I've tried enclosing the text in <pre></pre> tags before the text is assigne
d to the label and it works fine except for 2 things. The text is rendered i
n a non-styled font and in the instance that the user entered really long te
xt and didn't manullay hit
a carriage return- which causes the text continue to the right instead of au
tomatically wrapping even though I define a width on my label, the cell the
label is within, etc..
Does anyone know how to get this to work? I must have looked around on the n
et for hours!set the text box Text Mode property to MultiLine.
Av.
"Tony" <anonymous@.discussions.microsoft.com> wrote in message
news:7B9C3796-02D8-4180-AD93-8572746CD951@.microsoft.com...
> Hello,
> Im can't seem to figure this out OR find any documentation on if it's
> possible; I need to populate the value of an asp:label with text retrieved
> from the database. However when the text is populated I need to retain
> carriage returns and indents that the text contains. That way if I want to
> see this:
> Some text with a manual
> carriage return.
> 1. this is one.
> 2. this is two.
> It doesn't look like this:
> Some text with a manual carriage return. 1. this is one. 2. this is two.
> I've tried enclosing the text in <pre></pre> tags before the text is
> assigned to the label and it works fine except for 2 things. The text is
> rendered in a non-styled font and in the instance that the user entered
> really long text and didn't manullay hit a carriage return- which causes
> the text continue to the right instead of automatically wrapping even
> though I define a width on my label, the cell the label is within, etc..
> Does anyone know how to get this to work? I must have looked around on the
> net for hours!
>
TextMode is not a property for a label but a textbox. I have tried using a t
extbox control with this property set to multiline previously however withou
t specifically setting the height of the textbox I end up with vertical scro
llbars- which I cannot have
because this is for a printable report.
Hi, Tony
You might write a function to conver the strin, like:
'Get str from database
str = "Some text with a manual carriage return." & vbCr & vbTab & "1. this i
s one. " & vbNewLine & vbTab & "2. this is two."
str = Replace(str, " ", " ")
str = Replace(str, vbTab, " ") 'De
pend how many spaces do you want for a tab.
str = Replace(str, vbNewLine, "<br/>")
str = Replace(str, vbCr, "<br/>")
str = Replace(str, vbLf, "<br/>")
Label1.Text = str
Hope this helps,
Bin Song, MCP
even better ..use a StringBuilder :)
Swanand Mokashi
Microsoft Certified Solution Developer (.NET)
Microsoft Certified Application Developer (.NET)
http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"Bin Song, MCP" <anonymous@.discussions.microsoft.com> wrote in message
news:E9930659-B6E5-47F0-A42E-88BE5B97B7A9@.microsoft.com...
> Hi, Tony
> You might write a function to conver the strin, like:
> 'Get str from database
> str = "Some text with a manual carriage return." & vbCr & vbTab &
"1. this is one. " & vbNewLine & vbTab & "2. this is two."
> str = Replace(str, " ", " ")
> str = Replace(str, vbTab, " ") '
Depend
how many spaces do you want for a tab.
> str = Replace(str, vbNewLine, "<br/>")
> str = Replace(str, vbCr, "<br/>")
> str = Replace(str, vbLf, "<br/>")
> Label1.Text = str
> Hope this helps,
> Bin Song, MCP
>
The problem is that there is no universally accepted definition of how
preformatted ascii text should be rendered on the web. You just have
to munge it yourself. In the case you gave I would suggest something
like:
outputLabel.Text = dbText.Replace(@."\n", "<BR>").Replace(@."\t",
@." ");
There is no "easy way out" that I'm aware of.
Hope that helps
Ian
"Tony" <anonymous@.discussions.microsoft.com> wrote in message news:<7B9C3796-02D8-4180-AD93
-8572746CD951@.microsoft.com>...
> Hello,
> Im can't seem to figure this out OR find any documentation on if it's possible; I
need to populate the value of an asp:label with text retrieved from the database. Ho
wever when the text is populated I need to retain carriage returns and indents that
the
text contains. That way if I want to see this:
> Some text with a manual
> carriage return.
> 1. this is one.
> 2. this is two.
> It doesn't look like this:
> Some text with a manual carriage return. 1. this is one. 2. this is two.
> I've tried enclosing the text in <pre></pre> tags before the text is
assigned to the label and it works fine except for 2 things. The text
is rendered in a non-styled font and in the instance that the user
entered really long text and didn't manullay hit a carriage return-
which causes the text continue to the right instead of automatically
wrapping even though I define a width on my label, the cell the label
is within, etc..
> Does anyone know how to get this to work? I must have looked around on the net for
hours!
AWESOME!! Thanks Ian!! All I had to do is lose the '@.' sign (not sure if it'
s because I use C#) and it works. I cannot tell you how freakin ecstatic I a
m that your solution worked. Thank you!
populate datagrid from listbox value
the value in the listbox I need to then populate a datagrid with detailed
information for the highlighted row.
How can i do that?Try this?
ASP.NET: Master/Detail View using a DropDownList and a DataGrid
[url]http://authors.aspalliance.com/aldotnet/examples/masterdetail_ddl_datagrid.aspx[/u
rl]
"Mike" <me@.me.com> wrote in message
news:ORHOgJWXEHA.2364@.TK2MSFTNGP12.phx.gbl...
>I have to populate a list box from a db table and when the user clicks on
> the value in the listbox I need to then populate a datagrid with detailed
> information for the highlighted row.
> How can i do that?
>
populate datagrid from listbox value
the value in the listbox I need to then populate a datagrid with detailed
information for the highlighted row.
How can i do that?Try this?
ASP.NET: Master/Detail View using a DropDownList and a DataGrid
http://authors.aspalliance.com/aldo...l_datagrid.aspx
"Mike" <me@.me.com> wrote in message
news:ORHOgJWXEHA.2364@.TK2MSFTNGP12.phx.gbl...
>I have to populate a list box from a db table and when the user clicks on
> the value in the listbox I need to then populate a datagrid with detailed
> information for the highlighted row.
> How can i do that?
Saturday, March 24, 2012
Populate drop down list with sql query (contains IF)
I have a drop down list and it is to get it's 'text' and 'value' from a table. The table contains 3 columns:
Title, Name, Id1, Id2
if Id1 is NOT blank then the 'text' value of the drop down list should be:
Name + "(" + Id1 + ")"
else
Name + "(" + Id2 + ")"
I believe the easiest way is to construct the above IF statement is to use SQL query, then pass the parameter to the DataTextField property. However, i seemed to be getting an error. Also any help on the SQL IF statement will be appreciated...
This is what i have so far...(without the IF statement as i'm not sure how to construct the IF statement in SQL)
Sub Page_Load(sender as Object, e as EventArgs)
If Not Page.IsPostBack Then
dropDownList.DataSource = ToGetDataTable()
dropDownList.DataValueField = "MyNewColumn"
dropDownList.DataTextField = "Name"
dropDownList.DataBind()
End if
End Sub
Function ToGetDataTable() As System.Data.IDataReader
Dim connectionString As String = "server='(local)';..................."
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT Title, Name + ' ( ' + Id1 + ')' AS MyNewColumn FROM MyTableName"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Do you have sufficient rights on your SQL Server box to create auser-defined function? That seems to be the best way to go aboutthis; you would simply select Title, Name (which is a terrible name fora database field), and MyFunction(Name, Id1, Id2) where MyFunctionwould do the work.
If you don't have this option, you could pull all necessary columns,put them into a DataTable, and then run through it, appending theappropriate values in one particular column.
Populate Dropdownlist with arraylist
Thank you
<code>
'********************************************************************************
'********************************************************************************
Private Sub insertTables()
'********************************************************************************
Dim lstColums As New ArrayList
lstColums.Add(New ListItem("Software", "Cl_Systems.Software"))
lstColums.Add(New ListItem("SystemType", "Cl_Systems.Software"))
lstColums.Add(New ListItem("SystemPurchaseDate", "Cl_Systems.SystemPurchaseDate"))
lstColums.Add(New ListItem("ServicePlan", "Cl_Systems.ServicePlan"))
lstColums.Add(New ListItem("ServicePlan_Purchase", "Cl_Systems.ServicePlan"))
lstColums.Add(New ListItem("ServicePlan_WarrentyEnd", "Cl_Systems.WarrentyEnd"))
lstColums.Add(New ListItem("ServicePlan_RenewalDate", "Cl_Systems.RenewalDate"))
lstColums.Add(New ListItem("BuiltID", "Cl_Systems.BuiltID"))
lstColums.Add(New ListItem("Software Version", "Cl_Systems.Version"))
lstColums.Add(New ListItem("Modules", "Cl_Systems.Modules"))
lstColums.Add(New ListItem("Packages", "Cl_Systems.Packages"))
lstColums.Insert(0, "--Select Field--")
ddFields.DataSource = lstColums
ddFields.DataBind()
End Sub
</code>
You added this "lstColums.Insert(0, "--Select Field--")" at the first posion which is "0" and you didn't set your selectedvalue when the DDL loaded, so the default selectedvalue is the first one.
Event if I take that line away it give me the same result.
Are you really creating the list like this? If so, I suggest either (a) creating a ListItemCollection instead, or (b) skipping the intermediate object altogether and just adding the items to the dropdownlist's Items collection.
Populate foreign key in InsertTemplate of FormView
How would I populate a foreign key value in a label field of a FormView when
FormView changes mode to Insert? So that I can insert foreign key.
Explanation:
Suppose there are two tables in database, EMPLOYEE (list of employees) and
EMPLOYEE_DOCS (list of documents of every employee). table EMPLOYEE_DOCS
have a foreign key field EMPLOYEE_ID. When I use FormView's Insert mode for
EMPLOYEE_DOCS, I want to to explicitly take foreign key, so that it wont go
blank when inserting in database or user wont need to type it. I have
everything in Panels (webcontrol)
Thank you for help.
MirajThanks all, I figured out
I did this:
Protected Sub FormView1_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertEventArgs) Handles
FormView1.ItemInserting
e.Values("EMPLOYEE_ID") =
GridView1.Rows(GridView1.SelectedIndex).Cells(1).T ext ' cells(1).text is the
foreign key
End Sub
"Miraj Haq" <mirajhaq-n-o-s-p-a-m@.yahoo.com> wrote in message
news:epbuhXYhFHA.1444@.TK2MSFTNGP10.phx.gbl...
> Hello all,
> How would I populate a foreign key value in a label field of a FormView
> when FormView changes mode to Insert? So that I can insert foreign key.
> Explanation:
> Suppose there are two tables in database, EMPLOYEE (list of employees) and
> EMPLOYEE_DOCS (list of documents of every employee). table EMPLOYEE_DOCS
> have a foreign key field EMPLOYEE_ID. When I use FormView's Insert mode
> for EMPLOYEE_DOCS, I want to to explicitly take foreign key, so that it
> wont go blank when inserting in database or user wont need to type it. I
> have everything in Panels (webcontrol)
> Thank you for help.
> Miraj
populate public property from a function
values generated by the control.
When I assign the value of the property to a function in the control, which
creates the values, I get a compilation error that says
the function doesn't have all the other property values to work with.
So, how do I populate the arraylist as a public property, so I can use it in
my web page ?
========== code in use ==========
I create the property wth the webpage by:
............
Dim arrTempList As New ArrayList()
oThis.myArrayList = arrTempList
...........
I have the the property defined in the control as:
...............
Public arrChartList As Arraylist
Public Property myArrayList As ArrayList
Get
Return arrChartList
End Get
Set
arrChartList = myfunction() '<--builds values for arraylist
End Set
End Property
.................Where is 'myfunction' declared? This looks like a scoping issue.
I am also
ignore the argument and just call a function. Why bother having a Set on the
property to begin with? People are going to be setting the property to
something - but that something will be complete ignored? Very confusing.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>I have a public property in my server control and I want to populate it
>with values generated by the control.
> When I assign the value of the property to a function in the control,
> which creates the values, I get a compilation error that says the function
> doesn't have all the other property values to work with.
> So, how do I populate the arraylist as a public property, so I can use it
> in my web page ?
>
> ========== code in use ==========
> I create the property wth the webpage by:
> ............
> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList
> ...........
>
> I have the the property defined in the control as:
> ...............
> Public arrChartList As Arraylist
> Public Property myArrayList As ArrayList
> Get
> Return arrChartList
> End Get
> Set
> arrChartList = myfunction() '<--builds values for arraylist
> End Set
> End Property
> .................
>
>
"myfunction" is in the control.
Yes, I am totally
what should I be doing ?
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.
phx.gbl...
> Where is 'myfunction' declared? This looks like a scoping issue.
> I am also
ore the argument and just call a function. Why bother
> having a Set on the property to begin with? People are going to be setting
the property to something - but that something will be
> complete ignored? Very confusing.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:
evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>
That depends on what you are trying to do in the first place. You either
want the user to assign a value to the property or you don't and want to
assign the variable a value returned by a function instead.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
> "myfunction" is in the control.
> Yes, I am totally
> what should I be doing ?
>
>
> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message
> news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>
I want the property to have the value created by the function.
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:uW8uI$PSGHA.1780@.TK2MSFTNGP12.ph
x.gbl...
> That depends on what you are trying to do in the first place. You either w
ant the user to assign a value to the property or you
> don't and want to assign the variable a value returned by a function inste
ad.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:
%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
>
populate public property from a function
When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that says
the function doesn't have all the other property values to work with.
So, how do I populate the arraylist as a public property, so I can use it in my web page ?
========== code in use ==========
I create the property wth the webpage by:
............
Dim arrTempList As New ArrayList()
oThis.myArrayList = arrTempList
............
I have the the property defined in the control as:
................
Public arrChartList As Arraylist
Public Property myArrayList As ArrayList
Get
Return arrChartList
End Get
Set
arrChartList = myfunction() '<--builds values for arraylist
End Set
End Property
..................Where is 'myfunction' declared? This looks like a scoping issue.
I am also confused why in the Set for a property, you would completely
ignore the argument and just call a function. Why bother having a Set on the
property to begin with? People are going to be setting the property to
something - but that something will be complete ignored? Very confusing.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>I have a public property in my server control and I want to populate it
>with values generated by the control.
> When I assign the value of the property to a function in the control,
> which creates the values, I get a compilation error that says the function
> doesn't have all the other property values to work with.
> So, how do I populate the arraylist as a public property, so I can use it
> in my web page ?
>
> ========== code in use ==========
> I create the property wth the webpage by:
> ............
> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList
> ...........
>
> I have the the property defined in the control as:
> ...............
> Public arrChartList As Arraylist
> Public Property myArrayList As ArrayList
> Get
> Return arrChartList
> End Get
> Set
> arrChartList = myfunction() '<--builds values for arraylist
> End Set
> End Property
> .................
"myfunction" is in the control.
Yes, I am totally confused on this and really need help.
what should I be doing ?
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
> Where is 'myfunction' declared? This looks like a scoping issue.
> I am also confused why in the Set for a property, you would completely ignore the argument and just call a function. Why bother
> having a Set on the property to begin with? People are going to be setting the property to something - but that something will be
> complete ignored? Very confusing.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>I have a public property in my server control and I want to populate it with values generated by the control.
>>
>> When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that
>> says the function doesn't have all the other property values to work with.
>>
>> So, how do I populate the arraylist as a public property, so I can use it in my web page ?
>>
>>
>> ========== code in use ==========
>> I create the property wth the webpage by:
>>
>> ............
>> Dim arrTempList As New ArrayList()
>> oThis.myArrayList = arrTempList
>> ...........
>>
>>
>> I have the the property defined in the control as:
>>
>> ...............
>> Public arrChartList As Arraylist
>> Public Property myArrayList As ArrayList
>> Get
>> Return arrChartList
>> End Get
>> Set
>> arrChartList = myfunction() '<--builds values for arraylist
>> End Set
>> End Property
>> .................
>>
>>
>>
That depends on what you are trying to do in the first place. You either
want the user to assign a value to the property or you don't and want to
assign the variable a value returned by a function instead.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
> "myfunction" is in the control.
> Yes, I am totally confused on this and really need help.
> what should I be doing ?
>
>
> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message
> news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>> Where is 'myfunction' declared? This looks like a scoping issue.
>>
>> I am also confused why in the Set for a property, you would completely
>> ignore the argument and just call a function. Why bother having a Set on
>> the property to begin with? People are going to be setting the property
>> to something - but that something will be complete ignored? Very
>> confusing.
>>
>> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
>> news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>>I have a public property in my server control and I want to populate it
>>>with values generated by the control.
>>>
>>> When I assign the value of the property to a function in the control,
>>> which creates the values, I get a compilation error that says the
>>> function doesn't have all the other property values to work with.
>>>
>>> So, how do I populate the arraylist as a public property, so I can use
>>> it in my web page ?
>>>
>>>
>>> ========== code in use ==========
>>> I create the property wth the webpage by:
>>>
>>> ............
>>> Dim arrTempList As New ArrayList()
>>> oThis.myArrayList = arrTempList
>>> ...........
>>>
>>>
>>> I have the the property defined in the control as:
>>>
>>> ...............
>>> Public arrChartList As Arraylist
>>> Public Property myArrayList As ArrayList
>>> Get
>>> Return arrChartList
>>> End Get
>>> Set
>>> arrChartList = myfunction() '<--builds values for
>>> arraylist
>>> End Set
>>> End Property
>>> .................
>>>
>>>
>>>
>>
>>
I want the property to have the value created by the function.
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:uW8uI$PSGHA.1780@.TK2MSFTNGP12.phx.gbl...
> That depends on what you are trying to do in the first place. You either want the user to assign a value to the property or you
> don't and want to assign the variable a value returned by a function instead.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
>> "myfunction" is in the control.
>>
>> Yes, I am totally confused on this and really need help.
>>
>> what should I be doing ?
>>
>>
>>
>>
>>
>> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>>> Where is 'myfunction' declared? This looks like a scoping issue.
>>>
>>> I am also confused why in the Set for a property, you would completely ignore the argument and just call a function. Why bother
>>> having a Set on the property to begin with? People are going to be setting the property to something - but that something will
>>> be complete ignored? Very confusing.
>>>
>>> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>>>I have a public property in my server control and I want to populate it with values generated by the control.
>>>>
>>>> When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that
>>>> says the function doesn't have all the other property values to work with.
>>>>
>>>> So, how do I populate the arraylist as a public property, so I can use it in my web page ?
>>>>
>>>>
>>>> ========== code in use ==========
>>>> I create the property wth the webpage by:
>>>>
>>>> ............
>>>> Dim arrTempList As New ArrayList()
>>>> oThis.myArrayList = arrTempList
>>>> ...........
>>>>
>>>>
>>>> I have the the property defined in the control as:
>>>>
>>>> ...............
>>>> Public arrChartList As Arraylist
>>>> Public Property myArrayList As ArrayList
>>>> Get
>>>> Return arrChartList
>>>> End Get
>>>> Set
>>>> arrChartList = myfunction() '<--builds values for arraylist
>>>> End Set
>>>> End Property
>>>> .................
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
populate text box from sql
Wednesday, March 21, 2012
populate value in dropdown
Thanks in advance.
<asp:DropDownListID="DDDept"runat="server"AutoPostBack="True" DataSourceID="ObjectDataSource1"DataTextField="DeptName"DataValueField="DeptID"Style="z-index: 112; left: 372px;position: absolute; top: 415px"Width="159px"></asp:DropDownList>
SO you have your datasource all set up and the drop down list displays the departments correctly. However you want the users current department to be selected..
use the SelectedValue Property of the drop down list and set it to whatever key field in the users table that has the department id in it.
<asp:DropDownList SelectedValue='<# Bind("DepartmentIdFieldFromUsersTable") %>' .../>
should do it.
hth,
mcm
Hi, Thank you so much for the help!! I can see the department correctly now !!
Populating a check boxlist with info from a database
I have a dropdown box with the value titleid. I also have a checkboxlist with the value of classificationid. How do I populate a checkboxlist when I change the selection in the dropdown?
I have this on pageload
Checkboxlist1.datasource="mystoredprocedure"
checkboxlist1.datatextfield = "description"
checkboxlist1.datavaluefield = "classificationid"
Checkboxlist.databind()
If checkboxlist1.items[i].value = "1' then
checkboxlist1.items[i].selected = true
else
checkboxlist1.items[i].selected = false
Do I need to put something in here to connect/bind to the dropdown box?
You need to handle the "SelectedIndexChanged" event of the dropdown, This event is raised when the selectedItem changes. Please also remember to set the "AutoPostBack" property of the dropdwn to true.
<asp:DropDownListID="DropDownList1"AutoPostBack="true"runat="server"OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"/>
protectedvoid DropDownList1_SelectedIndexChanged(object sender,EventArgs e)
{
//Bind the check box list here again and add any necessary logic you want might want
}s
If this helps please remember to mark post as answer.
Help I'm confused...
I have this as my dropdown:<asp:DropDownListID="DropDownList1"runat="server"DataSourceID="SqlDataSource1"
DataTextField="Title"DataValueField="TitleID"AutoPostBack="True"OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList><br/><asp:CheckBoxListID="CheckBoxList1"runat="server"DataSourceID="SqlDataSource2"
DataTextField="description"DataValueField="classificationid"RepeatColumns="5"RepeatDirection="Horizontal"BorderStyle="Dashed"CellPadding="2"CellSpacing="2"Height="247px"Width="762px"BorderColor="#CFB37D">
</asp:CheckBoxList><br/>
What do I put on the code behind page for the SelectedIndexChange to bring back the items in the database? If the titleID is selected I want check marks in the checkboxes (classificationid) to show what the user has selected already. Please help!
ProtectedSub CheckBoxList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles CheckBoxList1.SelectedIndexChangedEndSub
Okay I've figured some things out... Here's my stored procedure:
CREATE Procedure GetClassID
@.titleid int
AS
SELECT
classifications.[description], titleclassification.classificationid
FROM
classifications inner join titleclassification on titleclassification.classificationid = classifications.classificationid
wheretitleid=@.titleid
GO
I'm trying to code the checkboxlist and having problems
ProtectedSub CheckBoxList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles CheckBoxList1.SelectedIndexChangedDim iAsInteger
Dim chkbxAs CheckBoxListFor i = 0To chkbx.Items.Count - 1
Next
if chkbx.Items[i].SelectedValuethen
CheckBoxList1.Items([i].selected =True)Else
CheckBoxList1.Items([i].selected =False)EndIf
CheckBoxList1.DataBind()EndSub
what am I doing wrong?
Ok, i want to understand one thing. Based on which field do you want the items to be checked? You have 2 fields in your select SP, you need to have a third one and based on it, you set the the items to be checked or not.
I want the classificationid field to be checked. What's the other field to add and how do I set the items to be checked or not? Do I need a Boolean?
if your sql database classificationid field is set to 'bit' you wont need to do anything except checkboxlist1.databind()
it knows 1's are checks and vice versa.
edit: ok so you are using stored procedures. ive never done it that way. what i would do, which is pretty simple imo, is create a fresh checkbox list. let it create a sqldatasource for it. i use the nice little sql generator thing when i create it. select the 2 columns from your database. click the where button and use the control selected index thing. i hope im not being to vague. then lastly you will have to set the dropdownlist to autopostback.
Okay I tried it your way and got the same thing as my stored procedure but how do I get the items to be checked? What do I put for the codebehind
ProtectedSub CheckBoxList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles CheckBoxList1.SelectedIndexChanged
That's where I'm lost.
its not checkbox1 seletedindexchanged, its dropdownlist1 selectedindex changed. in that code snippet just put checkboxlist1.databind(). when a checkbox list is bound to a bit field, it will check the boxes that are true
please post your most recent aspx page code so i can look at your sqldatasource.
I can't change my classificationid field to a bit field because it will change the entire structure of my database. Ugh. Do I write a function like so to convert to a bit. Is this one okay.
CREATE FUNCTION [Converttobool]
(@.value char(1))
RETURNS bit
BEGIN
declare @.returnvalue bit
if @.value = 'y'
set @.returnvalue = 1
else
set @.returnvalue= 0
return @.returnvalue
END
i think you can just do it in your select statement
cast(columnname, bit)
This is what I have thus far it brings back my items from the database but it's not checked, any ideas?
ProtectedSub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChangedDim iAsInteger
For i = 0To CheckBoxList1.Items.Count - 1If (CheckBoxList1.Items(i).Selected)Then
Response.Write(CheckBoxList1.Items(i).Value)
EndIf
Next
EndSub
you dont need to manually check anything if youve databound it to the sqldatasource... its just checkboxlist1.databind()
Added it cast to my select statement
SELECT
classifications.[description], cast(titleclassification.classificationid as bit)
FROM
classifications inner join titleclassification on titleclassification.classificationid = classifications.classificationid
wheretitleid=@.titleid
Now I'm getting ...Databinding: System.Data.DataRowView does not contain a property with the name classificationid. Any suggestions?
Okay I got rid of the databinding error message, page comes up but still no items are checked? I'm going. I feel that I'm almost there any suggestions?
Here's my select statement:
SELECT
classifications.[description], cast(titleclassification.classificationid as bit)
FROM
classifications inner join titleclassification on titleclassification.classificationid = classifications.classificationid
wheretitleid=@.titleid
What do I put here?
ProtectedSub DropDownList1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles DropDownList1.SelectedIndexChangedCheckBoxList1.DataBind()
EndSubThanks if anyone can assist me!
Populating a DropDownList
How do I put the data in an array list and then sort it. Do you have an example.
How do you have a database valueand a display value in the array list ?
please i'm making a site in a page of this site i had two dropdownlist ,the first is for the comapny and the other is for the models products of one company...
how can i make the ddl of the company to be when i select one of them, the another ddl changes its contenent to be just the models of this company or this selection..
if any body know please post the codes and the html apperance codes
Populating a DropDownList
I nneed to insert a value and a display text.Yes, you may use " DropDownList.Items.Add" or "Items.Insert".
How do you add a value and a display text?
ddlb.Add("50","New York") does not work. It appears to only take one argument.
OK. Do it like this:
Dim newItem As ListItem = New ListItem("New York", "50")
ddlb.Items.Add(newItem)
This will add a new item at bottom of your DDL, if you want add it in a certain palce, you amy do like this:
ddlb.Items.Insert(0,newItem)
This will add it in the very top.
Friday, March 16, 2012
Populating a label (inside InsertItemTemplate) with default value
I have one GridView and two different DetailsView's on ONE SINGLE page. I'm attempting to populate a label (which is in a DetailsView and also inside an InsertItemTemplate) with a value from the GridView. Of course I have datasources (<asp:SqlDataSource>) which are feeding the GridView and two DetailsViews. I also have all the commands with the datasources (SelectCommand, InsertCommand, UpdateCommand, etc.)
The reason why I have the ONE GridView and TWO DetailsViews is because I'm working with THREE separate SQL tables.
Here's my code:
The GridView (which contains the value inside a LinkButton)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Tracker_Number" DataSourceID="TOASearchResults" Width="498px" AllowPaging="True" AllowSorting="True">
<asp:LinkButton ID="LinkButton2" CommandName="Select" Runat="Server" OnClick="ShowEdit" Text='<%# Eval("Tracker_Number") %>'/>
The DetailsView (which contains the label I want to populate)
<asp:TemplateField HeaderText="Tracker Number" SortExpression="Tracker_Number">
<EditItemTemplate>
<asp:label ID="TrackerNumber" runat="server" Text='<%# Bind("Tracker_Number") %>'></asp:label>
</EditItemTemplate>
<InsertItemTemplate>
<asp:label ID="lblTrackerNumber" runat="server"></asp:label>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="TrackerNumber" runat="server" Text='<%# Eval("Tracker_Number") %>'></asp:label>
</ItemTemplate>
</asp:TemplateField>
I basically took this project over, so this isn't even my code. However, everything works except for this little part.
Any help would be appreciated,
Thanks!
-WesSo what's populating your DetailsView? The same data source? If everything else seems to be working, I think you should step through your code to see if those statements in the DetailsView are being called. (Too bad you use inline ASP.NET! ha ha!)
I got it!
I basically passed the value of the LinkButton (which was whatever the user clicked), stored it into a label and then assigned the value of that label to the label inside my InsertItemTemplate.
Thanks for the help anyway!
Populating a Textbox
How can I populate a textbox with a value retreived from a SQL database so that it is editable?
Thank you!There's no true data binding in ASP; you've got to write code to retrieve the value and more code to update it. The following code will retrieve the value. You'll also need an Update query to update the value.
Good luck
<code>
Dim oConnAsNew Data.SqlClient.SqlConnection(sConnect)
Dim oCmdAsNew Data.SqlClient.SqlCommand
Dim oDSAsNew DataSet
Dim oDAAsNew SqlClient.SqlDataAdapter
Try
With oCmd
.CommandText = "Select Value From Table1"
.Connection = oConn
EndWith
With oDA
.SelectCommand = oCmd
oConn.Open()
.Fill(oDS)Textbox1.text =ods.Tables(0).Rows(0).Item(0)
EndWith
</code>
What kind of object are you storing your value in? Is it just a single value you are getting back from the database? If so you could use the ExecuteScalar routine to put it into a string and then assign it to a text box. If you have it in a datatable, you just have to assign the proper cell to the text box:
textBox.Text = myDataTable.Rows(rowCounter).Cells("'myField")
As Mr Jkcnack said that if you are retrieving single value use ExecuteScaler method if you are retieving multiple values use dataReader.
Populating a text field and then getting its value
fine. I am using the latest Beta 2 release of .net framework.
Imran.
"Grant Merwitz" <grant@dotnet.itags.org.workshare.com> wrote in message
news:O0YmSUcmFHA.576@dotnet.itags.org.TK2MSFTNGP15.phx.gbl...
> Thats a strange one.
> Working fine for me:
> ASPX:
> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
> OnClick="Button1_Click"></asp:TextBox>
> <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
> CS
> void Page_Load(object sender, System.EventArgs e)
> {
> if(!Page.IsPostBack)
> TextBox1.Text = "Hello";
> }
> void Button1_Click(object sender, System.EventArgs e)
> {
> Response.Write("Value: " + TextBox1.Text);
> }
> OUTPUT
> Value: Hello
>
> Try making a simple page like that and testing it
>
> "Imran Aziz" <imran@dotnet.itags.org.tb2.net> wrote in message
> news:e43rNIcmFHA.2860@dotnet.itags.org.TK2MSFTNGP15.phx.gbl...
>> Hello All,
>> I am populating a text field dynamic in my code, and its a read-only
>> textbox control. It populates it perfectly fine. but when I get its value
>> back in code I get an empty string any clues as to how to get this sorted
>> please ?
>>
>> Here is how I set the value of the control.
>> txtTitle.Text = feed.Channels[0].Title;
>>
>> and get it later
>>
>> String strString = txtTitle.Text;
>>
>> Any clues please ?
>>
>> Imran.
>>okay, i'm on v1.1
I have beta 2 on a machine here.
If i have time to test it before i go, i'll try run the example there
"Imran Aziz" <imran@.tb2.net> wrote in message
news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
> If I change the textbox property Readonly to false then it works
> perfectly fine. I am using the latest Beta 2 release of .net framework.
> Imran.
> "Grant Merwitz" <grant@.workshare.com> wrote in message
> news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
>> Thats a strange one.
>> Working fine for me:
>>
>> ASPX:
>>
>> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
>> OnClick="Button1_Click"></asp:TextBox>
>> <asp:Button id="Button1" runat="server"
>> Text="Button"></asp:Button>
>>
>> CS
>>
>> void Page_Load(object sender, System.EventArgs e)
>> {
>> if(!Page.IsPostBack)
>> TextBox1.Text = "Hello";
>> }
>>
>> void Button1_Click(object sender, System.EventArgs e)
>> {
>> Response.Write("Value: " + TextBox1.Text);
>> }
>>
>> OUTPUT
>>
>> Value: Hello
>>
>>
>> Try making a simple page like that and testing it
>>
>>
>> "Imran Aziz" <imran@.tb2.net> wrote in message
>> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>> Hello All,
>>> I am populating a text field dynamic in my code, and its a read-only
>>> textbox control. It populates it perfectly fine. but when I get its
>>> value back in code I get an empty string any clues as to how to get this
>>> sorted please ?
>>>
>>> Here is how I set the value of the control.
>>> txtTitle.Text = feed.Channels[0].Title;
>>>
>>> and get it later
>>>
>>> String strString = txtTitle.Text;
>>>
>>> Any clues please ?
>>>
>>> Imran.
>>>
>>
>>
Thanks a lot.
Imran.
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:u9$zKbdmFHA.3936@.TK2MSFTNGP10.phx.gbl...
> okay, i'm on v1.1
> I have beta 2 on a machine here.
> If i have time to test it before i go, i'll try run the example there
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>> If I change the textbox property Readonly to false then it works
>> perfectly fine. I am using the latest Beta 2 release of .net framework.
>> Imran.
>>
>> "Grant Merwitz" <grant@.workshare.com> wrote in message
>> news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
>>> Thats a strange one.
>>> Working fine for me:
>>>
>>> ASPX:
>>>
>>> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
>>> OnClick="Button1_Click"></asp:TextBox>
>>> <asp:Button id="Button1" runat="server"
>>> Text="Button"></asp:Button>
>>>
>>> CS
>>>
>>> void Page_Load(object sender, System.EventArgs e)
>>> {
>>> if(!Page.IsPostBack)
>>> TextBox1.Text = "Hello";
>>> }
>>>
>>> void Button1_Click(object sender, System.EventArgs e)
>>> {
>>> Response.Write("Value: " + TextBox1.Text);
>>> }
>>>
>>> OUTPUT
>>>
>>> Value: Hello
>>>
>>>
>>> Try making a simple page like that and testing it
>>>
>>>
>>> "Imran Aziz" <imran@.tb2.net> wrote in message
>>> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>>> Hello All,
>>>> I am populating a text field dynamic in my code, and its a read-only
>>>> textbox control. It populates it perfectly fine. but when I get its
>>>> value back in code I get an empty string any clues as to how to get
>>>> this sorted please ?
>>>>
>>>> Here is how I set the value of the control.
>>>> txtTitle.Text = feed.Channels[0].Title;
>>>>
>>>> and get it later
>>>>
>>>> String strString = txtTitle.Text;
>>>>
>>>> Any clues please ?
>>>>
>>>> Imran.
>>>>
>>>
>>>
>>
>>
Sorry it took me so long to try this.
But it's working fine for me on a Machine running Beta 2
"Imran Aziz" <imran@.tb2.net> wrote in message
news:ujgDxxdmFHA.2472@.TK2MSFTNGP15.phx.gbl...
> Thanks a lot.
> Imran.
> "Grant Merwitz" <grant@.workshare.com> wrote in message
> news:u9$zKbdmFHA.3936@.TK2MSFTNGP10.phx.gbl...
>> okay, i'm on v1.1
>>
>> I have beta 2 on a machine here.
>> If i have time to test it before i go, i'll try run the example there
>>
>> "Imran Aziz" <imran@.tb2.net> wrote in message
>> news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>> If I change the textbox property Readonly to false then it works
>>> perfectly fine. I am using the latest Beta 2 release of .net framework.
>>> Imran.
>>>
>>> "Grant Merwitz" <grant@.workshare.com> wrote in message
>>> news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
>>>> Thats a strange one.
>>>> Working fine for me:
>>>>
>>>> ASPX:
>>>>
>>>> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
>>>> OnClick="Button1_Click"></asp:TextBox>
>>>> <asp:Button id="Button1" runat="server"
>>>> Text="Button"></asp:Button>
>>>>
>>>> CS
>>>>
>>>> void Page_Load(object sender, System.EventArgs e)
>>>> {
>>>> if(!Page.IsPostBack)
>>>> TextBox1.Text = "Hello";
>>>> }
>>>>
>>>> void Button1_Click(object sender, System.EventArgs e)
>>>> {
>>>> Response.Write("Value: " + TextBox1.Text);
>>>> }
>>>>
>>>> OUTPUT
>>>>
>>>> Value: Hello
>>>>
>>>>
>>>> Try making a simple page like that and testing it
>>>>
>>>>
>>>> "Imran Aziz" <imran@.tb2.net> wrote in message
>>>> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>>>> Hello All,
>>>>> I am populating a text field dynamic in my code, and its a
>>>>> read-only textbox control. It populates it perfectly fine. but when I
>>>>> get its value back in code I get an empty string any clues as to how
>>>>> to get this sorted please ?
>>>>>
>>>>> Here is how I set the value of the control.
>>>>> txtTitle.Text = feed.Channels[0].Title;
>>>>>
>>>>> and get it later
>>>>>
>>>>> String strString = txtTitle.Text;
>>>>>
>>>>> Any clues please ?
>>>>>
>>>>> Imran.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
Hum strange I am doing something wrong then, I guess I will try and use
labels instead of text boxes.
Thanks a lot for coming back to me on that.
Imran
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:eUjjZmNnFHA.3572@.TK2MSFTNGP09.phx.gbl...
> Sorry it took me so long to try this.
> But it's working fine for me on a Machine running Beta 2
>
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:ujgDxxdmFHA.2472@.TK2MSFTNGP15.phx.gbl...
>> Thanks a lot.
>> Imran.
>> "Grant Merwitz" <grant@.workshare.com> wrote in message
>> news:u9$zKbdmFHA.3936@.TK2MSFTNGP10.phx.gbl...
>>> okay, i'm on v1.1
>>>
>>> I have beta 2 on a machine here.
>>> If i have time to test it before i go, i'll try run the example there
>>>
>>> "Imran Aziz" <imran@.tb2.net> wrote in message
>>> news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>>> If I change the textbox property Readonly to false then it works
>>>> perfectly fine. I am using the latest Beta 2 release of .net framework.
>>>> Imran.
>>>>
>>>> "Grant Merwitz" <grant@.workshare.com> wrote in message
>>>> news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
>>>>> Thats a strange one.
>>>>> Working fine for me:
>>>>>
>>>>> ASPX:
>>>>>
>>>>> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
>>>>> OnClick="Button1_Click"></asp:TextBox>
>>>>> <asp:Button id="Button1" runat="server"
>>>>> Text="Button"></asp:Button>
>>>>>
>>>>> CS
>>>>>
>>>>> void Page_Load(object sender, System.EventArgs e)
>>>>> {
>>>>> if(!Page.IsPostBack)
>>>>> TextBox1.Text = "Hello";
>>>>> }
>>>>>
>>>>> void Button1_Click(object sender, System.EventArgs e)
>>>>> {
>>>>> Response.Write("Value: " + TextBox1.Text);
>>>>> }
>>>>>
>>>>> OUTPUT
>>>>>
>>>>> Value: Hello
>>>>>
>>>>>
>>>>> Try making a simple page like that and testing it
>>>>>
>>>>>
>>>>> "Imran Aziz" <imran@.tb2.net> wrote in message
>>>>> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>>>>>> Hello All,
>>>>>> I am populating a text field dynamic in my code, and its a
>>>>>> read-only textbox control. It populates it perfectly fine. but when I
>>>>>> get its value back in code I get an empty string any clues as to how
>>>>>> to get this sorted please ?
>>>>>>
>>>>>> Here is how I set the value of the control.
>>>>>> txtTitle.Text = feed.Channels[0].Title;
>>>>>>
>>>>>> and get it later
>>>>>>
>>>>>> String strString = txtTitle.Text;
>>>>>>
>>>>>> Any clues please ?
>>>>>>
>>>>>> Imran.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
Populating a text field and then getting its value
I am populating a text field dynamic in my code, and its a read-only
textbox control. It populates it perfectly fine. but when I get its value
back in code I get an empty string any clues as to how to get this sorted
please ?
Here is how I set the value of the control.
txtTitle.Text = feed.Channels[0].Title;
and get it later
String strString = txtTitle.Text;
Any clues please ?
Imran.Thats a strange one.
Working fine for me:
ASPX:
<asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
OnClick="Button1_Click"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
CS
void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
TextBox1.Text = "Hello";
}
void Button1_Click(object sender, System.EventArgs e)
{
Response.Write("Value: " + TextBox1.Text);
}
OUTPUT
Value: Hello
Try making a simple page like that and testing it
"Imran Aziz" <imran@.tb2.net> wrote in message
news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
> Hello All,
> I am populating a text field dynamic in my code, and its a read-only
> textbox control. It populates it perfectly fine. but when I get its value
> back in code I get an empty string any clues as to how to get this sorted
> please ?
> Here is how I set the value of the control.
> txtTitle.Text = feed.Channels[0].Title;
> and get it later
> String strString = txtTitle.Text;
> Any clues please ?
> Imran.
>
If I change the textbox property Readonly to false then it works perfectly
fine. I am using the latest Beta 2 release of .net framework.
Imran.
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
> Thats a strange one.
> Working fine for me:
> ASPX:
> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
> OnClick="Button1_Click"></asp:TextBox>
> <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
> CS
> void Page_Load(object sender, System.EventArgs e)
> {
> if(!Page.IsPostBack)
> TextBox1.Text = "Hello";
> }
> void Button1_Click(object sender, System.EventArgs e)
> {
> Response.Write("Value: " + TextBox1.Text);
> }
> OUTPUT
> Value: Hello
>
> Try making a simple page like that and testing it
>
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>
used the exact code, but does not work for me, the text value returned is
empty.
Imran.
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
> Thats a strange one.
> Working fine for me:
> ASPX:
> <asp:TextBox id="TextBox1" runat="server" ReadOnly="True"
> OnClick="Button1_Click"></asp:TextBox>
> <asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
> CS
> void Page_Load(object sender, System.EventArgs e)
> {
> if(!Page.IsPostBack)
> TextBox1.Text = "Hello";
> }
> void Button1_Click(object sender, System.EventArgs e)
> {
> Response.Write("Value: " + TextBox1.Text);
> }
> OUTPUT
> Value: Hello
>
> Try making a simple page like that and testing it
>
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:e43rNIcmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>
okay, i'm on v1.1
I have beta 2 on a machine here.
If i have time to test it before i go, i'll try run the example there
"Imran Aziz" <imran@.tb2.net> wrote in message
news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
> If I change the textbox property Readonly to false then it works
> perfectly fine. I am using the latest Beta 2 release of .net framework.
> Imran.
> "Grant Merwitz" <grant@.workshare.com> wrote in message
> news:O0YmSUcmFHA.576@.TK2MSFTNGP15.phx.gbl...
>
Thanks a lot.
Imran.
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:u9$zKbdmFHA.3936@.TK2MSFTNGP10.phx.gbl...
> okay, i'm on v1.1
> I have beta 2 on a machine here.
> If i have time to test it before i go, i'll try run the example there
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:%23rwRZUdmFHA.2860@.TK2MSFTNGP15.phx.gbl...
>
Sorry it took me so long to try this.
But it's working fine for me on a Machine running Beta 2
"Imran Aziz" <imran@.tb2.net> wrote in message
news:ujgDxxdmFHA.2472@.TK2MSFTNGP15.phx.gbl...
> Thanks a lot.
> Imran.
> "Grant Merwitz" <grant@.workshare.com> wrote in message
> news:u9$zKbdmFHA.3936@.TK2MSFTNGP10.phx.gbl...
>
Hum strange I am doing something wrong then, I guess I will try and use
labels instead of text boxes.
Thanks a lot for coming back to me on that.
Imran
"Grant Merwitz" <grant@.workshare.com> wrote in message
news:eUjjZmNnFHA.3572@.TK2MSFTNGP09.phx.gbl...
> Sorry it took me so long to try this.
> But it's working fine for me on a Machine running Beta 2
>
> "Imran Aziz" <imran@.tb2.net> wrote in message
> news:ujgDxxdmFHA.2472@.TK2MSFTNGP15.phx.gbl...
>