Hi, I am stuck on how to assign values on a label or text box.
The issue is the following:
I have two tables, one called A and the second one called B
Table A has tree fields: id, name, lastname
Table B has five fields: id, level1, level2, level3, level4
The idea is to save A.id into level1, level2, level3 and level4. A.id can be the same or not. I know how to assign and save the values on the DDBB using DDL, but when I want to show the values using labels, I get the first value always, this is becuase the
select command is configures in that way. If I use ddl instead label, it works, but I do not want to show the value using ddl. I want to use label to show the values, and ddl to modify or add new data into the DDBB.
SelectCommand="SELECT * FROM B WITH (INDEX (IX_B)) LEFT JOIN A ON B.level1 = A.ID"
<asp:SqlDataSource ID="sqlDSA" runat="server" ConnectionString="<%$ ConnectionStrings:psCS %>"
SelectCommand="SELECT * FROM A">
As you can see the level1 uses label, and level2 uses ddl, it was the only way to get the value for level2, otherwise if I use label on level2 it display level1 value instead.
I would like to know if there is any way to assign different value using anything but ddl.
Maybe I have to work on the Select command, but I do not how.
I have for columns, and each column usign its own value. Column one = value1, column two = value2, and so on.
Its like:
lblLabel1 = tableB.name
lblLabel2 = tableB.name
lblLabel3 = tableB.name
lblLabel4 = tableB.name
but each lblLabel# has or not same ID from tableB
I would like to use label instead to use ddl to show the info. I will use ddl to modify and add new values. It works, but label works only with value1.
table A has ID and names. table B has table A IDs only.
rcast
Member
2 Points
21 Posts
assigning values to label or text box or anything else, but DDL or radio button
Jun 10, 2012 06:20 AM|LINK
Hi, I am stuck on how to assign values on a label or text box.
The issue is the following:
I have two tables, one called A and the second one called B
Table A has tree fields: id, name, lastname
Table B has five fields: id, level1, level2, level3, level4
The idea is to save A.id into level1, level2, level3 and level4. A.id can be the same or not. I know how to assign and save the values on the DDBB using DDL, but when I want to show the values using labels, I get the first value always, this is becuase the select command is configures in that way. If I use ddl instead label, it works, but I do not want to show the value using ddl. I want to use label to show the values, and ddl to modify or add new data into the DDBB.
I am using <griedview>.
The code is as follow:
<asp:TemplateField HeaderText="Level 1" SortExpression="name"> <ItemTemplate><asp:Label ID="lblLevel1" runat="server" width="100" Text='<%# Bind("name") %>'></asp:Label></ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Level 2" SortExpression="name"> <ItemTemplate> <asp:DropDownList ID="ddlLevel2" runat="server" width="100" DataSourceID="sqlDSA" DataTextField="name" DataValueField="ID" SelectedValue='<%# Bind("level2") %>'></asp:DropDownList> </ItemTemplate> </asp:TemplateField><asp:SqlDataSource ID="sqlDSA" runat="server" ConnectionString="<%$ ConnectionStrings:psCS %>" SelectCommand="SELECT * FROM A">As you can see the level1 uses label, and level2 uses ddl, it was the only way to get the value for level2, otherwise if I use label on level2 it display level1 value instead.
I would like to know if there is any way to assign different value using anything but ddl.
Maybe I have to work on the Select command, but I do not how.
Tks.
gridview textbox label
nijhawan.sau...
All-Star
16436 Points
3176 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 10, 2012 07:33 AM|LINK
I suppose you want to bind multiple columns values to a single label control.
You can combine those columns in SQL abd give it a column name and then bind that column name to your label.
SELECT level1 + ' ,' + level2 + ' ,' + level3 + ' ,' + level4 AS CombinedLevel FROM Table
Then bind the CombinedLevel to your Label
gridview textbox label
rcast
Member
2 Points
21 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 10, 2012 11:49 AM|LINK
Hi,
I have for columns, and each column usign its own value. Column one = value1, column two = value2, and so on.
Its like:
lblLabel1 = tableB.name
lblLabel2 = tableB.name
lblLabel3 = tableB.name
lblLabel4 = tableB.name
but each lblLabel# has or not same ID from tableB
I would like to use label instead to use ddl to show the info. I will use ddl to modify and add new values. It works, but label works only with value1.
table A has ID and names. table B has table A IDs only.
Tks for your support.
gridview textbox label
rcast
Member
2 Points
21 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 12, 2012 03:58 AM|LINK
Someone can help me on this?
I will try to explain the situation in another way to simplify the question.
Table A has ID and name
Table B has level1 and level2
b.level1 = a.ID
b.level2 = a.ID
I wanto to display a.name using a label command, but seems like label is able to get the first value since I am doing join on A where a.ID=b.level1
I do not know how to get b.level2=a.ID at the same time b.level1=a.ID
it is like:
a.ID = 1
a.name = "John"
a.ID = 2
a.name = "Maria"
b.level1 = 1
b.level2 = 2
using label with level1 and 2:
eval("level1") it shows 1
eval("level2") it shows 2
using label with name:
eval("name") it shows John
eval("name") it shows John (here I need to shows Maria instead)
Tks!
gridview textbox label
isi_rajah19
Member
4 Points
4 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 12, 2012 01:16 PM|LINK
Rather add an ID to the to the table A to link the two tables and select from the table a and then retrive for Table B
isi_rajah19
Member
4 Points
4 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 12, 2012 01:17 PM|LINK
or you could create a view and select form a view.
rcast
Member
2 Points
21 Posts
Re: assigning values to label or text box or anything else, but DDL or radio button
Jun 12, 2012 01:26 PM|LINK
Hi. Table A has a field called ID. Both table are linked, but the second label get always the value of label one.