|
Dynamic controls created like this will not have viewstate persisted. When you use dynamic controls, you need to recreate it on every postback.
Michael Eber wrote:
(within PlaceHolder(insertHere).Controls)
Leg 1 textboxValue1 -invisible buttons-
Leg 2 textboxValue2 -invisible buttons-
Leg 3 textboxValue3 -invisible buttons-
Leg 4 _____________ [Next Leg] [Done]
What you need here is to display tabular data. GridView will be the best control and it handles viewstate very well. To get your desired result, use a GridView with necessary columns. Use TemplateColumn to display text box and button. When Create Leg is clicked, add a new row to the GridView 's data source and rebind the gridview.
|
|
|
|
|
Okay...I've been tinkering with this so far and have a few questions....
First: I have a dropdown box and I defined an OnSelectedIndexChange event. When I run the application and I select an item in the dropdown box, my next dropdown box is not populated!
UIPDATE: I believe I got this fixed. Set the dropdowns to AutoPageBack (or something like that).
Second: When I add dropdown lists to the GridView do I also use a TemplateColumn?
Finally: I must be using the TemplateColumn incorrectly. If it is in the Gridview it complains no such type exists.
If I add a <Column> header then add the TemplateColumn I get a different error. Where to I add the TemplateColumn?
Do I use a <Field> header instead?
modified on Monday, September 28, 2009 12:57 PM
|
|
|
|
|
On my page I have a plain Gridview Control.
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
In the code behind, I populate a dataview and bind it to the Gridview.
Me.GridView1.DataSource = objSF.DV
Me.GridView1.DataBind()
This works fine.
Now I want to change the formatting of column(4) to be formatted as currency.
I've tried, CType(Me.GridView1.Columns(4), BoundField).DataFormatString = "{0:c" , in various Gridview events with no success;
in fact, it appears that everywhere I try the above code, the Grid reports that there are no columns at all !
I've used, System.Diagnostics.Debug.WriteLine(Me.GridView1.Columns.Count.ToString) in the following events and gotten zero as a result.
GridView1_RowCreated
GridView1_DataBound
GridView1_PreRender
GridView1_RowDataBound
What am I doing wrong ?
How can I format a column to display the data as currency ?
Regards,
David
|
|
|
|
|
From ASP.NET 2.0 everything is encoded using HTMLEncode which prevents any modification being done to the bound controls. Just use like this :
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="CurrencyField" HeaderText="Amount" DataFormatString="{0:c}" HtmlEncode="false" />
</Columns>
</asp:GridView>
You can see I placed HtmlEncode=false .. This is required for every BoundField in Gridview to reformat the data.
I am hoping this would work...
|
|
|
|
|
You can also covert it in Template Field then format the value as you want and bind to the control in RowDataBound Event.
|
|
|
|
|
Thank you for your input. For now, I have traced back where the dataset is populated and used the following to format the data.
SQLcmd.Parameters("@ORDERVALUE").Value = String.Format("{0,15:c}", dAmt)
This is OK for now.
|
|
|
|
|
Hey David
You have solved your problem this way but it's not the efficient way to work if u r working on project following n tier architecture and MVC design pattern. In that case the data service should return the data in most common/raw format and then presentation layers should convert them as per the requirement. So if have multiple views using the same data service can display the data as per their requirements. They are not bound to display the original one.
|
|
|
|
|
Very true about returning data in a common format and have the presentation layer handle the formatting. I'll remember that in future designs.
Btw: This report is not finished, so it may get scrapped completely. A meeting with management is scheduled for this morning.
|
|
|
|
|
Hi..
How can I change the alert messages title..
thanks
By:
Hemant Thaker
|
|
|
|
|
Hemant Thaker wrote: How can I change the alert messages title..
You Can't !
The only thing you can do, create your alert using DIV. Make it Float. Use Custom Header Title and Button
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hemant Thaker wrote: How can I change the alert messages title..
No, You can not!
You can instead use custom alert boxes (and there are already many available on internet), look for them...
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.
|
|
|
|
|
|
|
Hi All,
I am getting 'sys' is undefined suddenly in one of the QA environemnt.
There are no code changes. it seems there is some environmental issue but not sure what is causing this issue.
I am saying there is no code issue as this code is working in other QA environment (present in other box)
a also checked the web.config it is same as in other environment too....
When checked with HTTP watch in the browser it seems that webresource.axd files are not getting downloaded
when it is trying to donwload the file server is giving 302 http error and redirecting to some error page
but for me page is redirecting properly with javascript error "sys is undefined"
Please let me know if any one has experienced the same issue
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
|
Thanks for the reply Manas .. let me chek
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Still not working ...
so do you know why ScriptResource.axd requests return 302 in my case ? intead of 200
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Do you have ASP.NET CTP installed.
302 is returned when Request is temporarily removed from the server. I think in your case, the id associated with the ScriptResource.axd which downloads the specific file got whacked.
Can you paste the script src in the browser addressbar directly and check whether the file is downloaded properly or not...??
|
|
|
|
|
Not sure what went wrong .....
now its working as expected ....
thanks all
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Yes...Thats great to hear that.
I have this error when I was using CTP version of Extensions. But I never found this when using in VS 2008.
Anyways..
Cheers.
|
|
|
|
|
hi every body
Im in big trouble please help me
im using obout grid control and ineed to put detailed grid inside it
the problem is how can i know the branch id that i need in the select query for the child grid
i try using OnRow databound method
but it give me null referance exception
this part of code
protected void OnGridRowDataBound(object sender, GridRowEventArgs e)
{
if (e.Row.RowIndex != -1 && e.Row.DataItem != null)
{
GridView GrdChildFind= new GridView();
GrdChildFind = (GridView)(e.Row.FindControl("grid2"));
GrdChildFind.DataSource = GetBranchInfo(((DataRowView)e.Row.DataItem)["Branch_Id"].ToString());
GrdChildFind.DataBind(); and this the definsion of detailed grid
<MasterDetailSettings LoadingMode="OnCallback" />
<DetailGrids>
<obout:DetailGrid runat="server" ID="grid2" AutoGenerateColumns="false"
AllowAddingRecords="true" ShowFooter="true" PageSize="5"
FolderStyle="styles/premiere_blue" ForeignKeys="Branch_Id"
OnInsertCommand="Insert2" OnUpdateCommand="Update2" OnDeleteCommand="Delate2">
<ClientSideEvents OnClientInsert="Insert2" OnClientUpdate="Update2" OnClientDelete="Delete2" />
<Columns>
|
|
|
|
|
janat_Al_donia wrote: Im in big trouble please help me
And you are creating same for us too by not even putting the code in pre tags.
janat_Al_donia wrote: im using obout grid control and ineed to put detailed grid inside it
I would suggest you to to rather use the obout forum for this.
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.
|
|
|
|
|
Check if e.Row.FindControl actually gets the GridView or not. In case of normal GridView we use e.Item.FindControl ...
|
|
|
|
|
Hi all,
i have developed a application in asp.net and vb.net, i was sending the mail by HTML format but i want 2 send this in .pdf format with the client images....please can any one help me......
Regards,
S.Inayat Basha.
|
|
|
|
|
inayat basha wrote: , i was sending the mail by HTML format but i want 2 send this in .pdf format with the client images...
You want to send these by attachment with Mail ? or what
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|