|
Hi,
I want to Bind Datalist Dynamically in Which depending upon the condition my table and it's fields are changing everytime.
Now I want to bind these records and display images dynamically.
e.g. I have table1 and table2 in which table1 contains 5 fields and table2 contains 3 fields. Now if condition is I want details from table1 then I want to bind the data to datalist.
Same as for if condition is table2.
How can I do?
Thanks
modified on Wednesday, April 23, 2008 6:44 AM
|
|
|
|
|
Your best bet is to manipulate your data source first, then bind to it.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks for the information.
Though If I bind the datasource.
But the fields are not same. if table1 contains no,name,image,MRP,Price then table2 will contains No,Name,Image.
and this is not only 2 table. There are near about 6-7 tables.
Thanks you
|
|
|
|
|
.... or i'm just not clever enough to get it.
Hi
I struggle over the same problem all the time and i know there are different solutions to handle it, but non of them makes me happy.
Imagine the following aspx-page:
<br />
<asp:Panel ID="Panel1" runat="server"></asp:Panel><br />
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder><br />
with the code:
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
TextBox t = new TextBox();<br />
t.Text = DateTime.Now.ToString();<br />
addLinkButton(" value 0 ");<br />
}<br />
private void addLinkButton(string value)<br />
{<br />
LinkButton b = new LinkButton();<br />
b.Text = value;<br />
b.Click += new System.EventHandler(testClick);<br />
PlaceHolder1.Controls.Add(b);<br />
}<br />
protected void testClick(object sender, EventArgs e)<br />
{<br />
PlaceHolder1.Controls.Clear();<br />
addLinkButton(" value 1 ");<br />
Label l = new Label();<br />
l.ID = "thelabel";<br />
l.Text = "the text";<br />
Panel1.Controls.Add(l);<br />
}<br />
<br />
After clicking the linkButton the second time the handler won't be fired. i know that i could set the Test of the linkButton different (i could define the button globally and access it by the variable name in the handler.the thing is: this example is just very simplified. the LinkButton might be some very complex structure. Example: A list of Controls including Controls. So if i build up the complex list in page_load and in the handler i need to move Controls to other positions its NOT an option to remove list-items from controls to add it at different places. on the other sideI might want to update a database in the event-handler and re-read the structure, like i re-created the linkButton with a different Text.
so what i need is the example above to be solved.
i'm very desperate about this problem
thanks for every input (and if possible i would love to have an explanation why the example doesnt work).
if i look at the page life cycle i cant see any problem creating the event-handler in a handler since i can create controls there. and of course a handler is part of a control!
|
|
|
|
|
Once you start dynamically adding controls in PAge_load or after, their viewstate will not be restored, so their events will not fire. One easy way around this is to have them just redirect to the same page with something on the URL telling you which link was pressed.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi Christian
Thank you for the answer. so far i have 4 solutions (your hint is one of them) to avoid the problem i have, but still: the way i would like to do it seems to be the 'natural way'. all the 'hacks' (at least from my point of view) dont satisfy me (i can be very stubborn ).
you gave me the last hint i needed: why it doesnt work. since i call the addLinkButton-method twice, the second time the viewstate wont be restored.
Yves
|
|
|
|
|
Hi
I am trying to update a field in a database using a stored procedure.
The field in the database is type smallint
The value that I am inserting is from a textbox, so I have the following code:
cmdsqlcommandupdate.Parameters.Add(new SqlParameter("@Height", SqlDbType.SmallInt));
cmdsqlcommandupdate.Parameters["@Height"].Value = tbheight.Text;
However it is not updating the field, when I hard code the value in, it updates
So I'm wondering do I need to convert the textbox value to int before I enter?
any help would be great
cheers!
|
|
|
|
|
.netman wrote: So I'm wondering do I need to convert the textbox value to int before I enter?
actually to a short, as thats the C# equivalent to SmallInt.
short.Parse or, btter still, short.TryParse
|
|
|
|
|
hi
thanks for the answer, however i tried the following and it didnt work:
cmdsqlcommandupdate.Parameters.Add(new SqlParameter("@Height", SqlDbType.SmallInt));
cmdsqlcommandupdate.Parameters["@Height"].Value = short.Parse(tbheight.Text)
it showed the error
'short' does not contain a definition for 'cmdsqlcommandupdate'
why would this be?
thanks so far
|
|
|
|
|
OK ignore that post i used this
short shorttest = short.Parse(tbheight.Text);
cmdsqlcommandupdate.Parameters.Add(new SqlParameter("@Height", SqlDbType.SmallInt));
cmdsqlcommandupdate.Parameters["@Height"].Value = shorttest;
but it is still not updating the field
The textbox where the value comes from is in a panel, the update button is in a different area , would this make a difference?
cheers
|
|
|
|
|
No, not in the slightest. Have you taken the params passed into the debugger and run them through the proc in your DB to see if the issue is your database code ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Because you don't have a semicolon at the end ?
You should use TryParse, or this code will blow up if the text is not a short.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Christian Graus wrote:</div>Because you don't have a semicolon at the end ?</blockquote>
I cant see where I am missing one from the statement above
I tried:
short shorttest = short.TryParse(tbheight.Text);
but it gives the error:
No overload for method 'TryParse' takes '1' arguments
Thanks christian
|
|
|
|
|
I guess if you paid attention to the intellisense, or read the docs...
short shorttest;
if ( short.TryParse(tbheight.Text, out shorttest))
{
// This means the parse was successful.
}
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
.netman wrote: No overload for method 'TryParse' takes '1' arguments
have you checked out the documentation for short.TryParse??
If you did you'll see it returns a boolean and has a second parameter.
short shorttest = 0;<br />
if(short.TryParse(tbHeight.Text, out shorttest)<br />
{<br />
}
|
|
|
|
|
OK
I think the problem runs deeper, I have just tried updating another field and it hasnt worked either, the field is a nvarchar
If i hardcode values in it works, but when I get them from textbox it doesnt
The texboxes are in panels but the update button is outside the panel, would this affect it?
thanks!
|
|
|
|
|
.netman wrote: The texboxes are in panels but the update button is outside the panel, would this affect it?
No, it shouldn't. When you set breakpoints, are the right values being found ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yeah the right values are found
The weird thing is, i am using one of the textboxes to find the correct field in the database and update that row.
It finds that textbox ok, but when I try and use any other textbox it just wont update
If I hardcode it does
Shall I post some code
I tried the
short shorttest;
if ( short.TryParse(tbheight.Text, out shorttest))
{
// This means the parse was successful.
}
but this didnt work either
|
|
|
|
|
OK, I've found the problem
Im so stupid!
Basically I had textfields which were displaying data from a database, this data was selected on pageload and applied to the textboxes
I moved this code to page init and it worked
how annoying
thanks for the help thouhg guys
|
|
|
|
|
can i write this code?
window.open('C:/webpart/a.htm')
or i should write a url instead of 'c:/webpart/a.htm'
|
|
|
|
|
window.open should use a URL, for reasons that I hope are obvious. Being javascript, it runs on the client, so cannot see your servers file system.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
does http protocol and its authentication remains same?? When it comes to mobile web form(in mobile browsers) and desktop webform(in normal IE/firefox...)
CAN U Give Me Various mobile web Browsers????
thanks,
Prashanth
prashanth,
s/w Engineer
|
|
|
|
|
Yes, if HTTP was not the same, it would not work.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks, But I was helpless, I mean I surfed in google too, but couldn't found my answer....
I want few test cases on Http Authentication for mobile browser..
Thanks,
|
|
|
|
|
Hello,
does anyone know of a asp.net control which has a ASP:SELECT with, when a list-item "Other" is selected, allows for a textbox where the user can enter an alternative answer besides the ones listed in the select?
Thansk a lot!
Morten
|
|
|
|