|
Hi Everybody!!!
I fill a DataGrid with a SQLServer Database, so far so good, but because the name of the fields were thought for internal development work, they're not friendly, so I have to change them, I do that in the ItemDataBound.
But here comes the problem: if I change the headers text, the SortCommand Event doesn't work. what I'm doing wrong? is there another way to change the headers text? or should I bind the grid in another way?
Thanks for your time.
Greetings from Mexico.
|
|
|
|
|
Actually the easiest thing to do would be to change the columns names in the query. Like this.
select column1 as NewColomnName from yourTable
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thanks ToddHileHoffer!!!
I did what you told me and it worked!!!
Now I'm just wondering how works the relation between the headers and that event...
|
|
|
|
|
white.thief wrote: if I change the headers text, the SortCommand Event doesn't work.
You can change the HeaderText with a friendly name, but you can keep the dev name in the SortExpression property of the column?
|
|
|
|
|
Hi minhpc_bk!
To your cuestion: No, I can´t. But, but with the advice of ToddHileHoffer all that I had to do was a little function that could make the traslation of the friendly names to the dev names, and that was it.
Greetings.
|
|
|
|
|
when you go to this page
http://www1.sprintpcs.com/explore/coverage/CoverageOverview.jsp?ATR_ExtraOne=Personal_Wireless_Plans_Coverage
and enter a zipcode and when u click the 'View coverage' image button, then you get the next page which shows whether you have coverage to the zipcode you entered. But i'm having problem when i do it through Csharp.Net. The problem is the zipcode value is not getting submitted through the image button.
this is the final page where it displays whether it has coverage or not.
http://www1.sprintpcs.com/explore/coverage/CoverageOverview.jsp?bmForm=SprintZipCodeToCSAComponentPlansFocus&bmFormID=1152889587027&bmUID=1152889587027&bmIsForm=true&bmPrevTemplate=explore%2Fcoverage%2FCoverageOverview.jsp&bmText=csaZip&csaZip=20171&bmImage=ShowPlans.x&bmImage=ShowPlans.y&bmImage=ReturnCSA.x&bmImage=ReturnCSA.y&bmHidden=FOLDER%3C%3Efolder_id&FOLDER%3C%3Efolder_id=1436777&bmHidden=CURRENT_USER%3C%3EATR_SCID&CURRENT_USER%3C%3EATR_SCID=ECOMM&bmHidden=CURRENT_USER%3C%3EATR_PCode&CURRENT_USER%3C%3EATR_PCode=None&bmHidden=CURRENT_USER%3C%3EATR_cartState&CURRENT_USER%3C%3EATR_cartState=group&bmFields=bmForm%2CbmFormID%2CbmUID%2CbmIsForm%2CbmPrevTemplate%2CbmText%2CbmImage%2CbmHidden&bmHash=84312c83205bfccaa4a01a0f0edbd2d4495bbd27&ReturnCSA.x=36&ReturnCSA.y=7
any help would be appreciated
|
|
|
|
|
well if its a button, then in the event you can read the value there before submit
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Hi,
I have the width of the fridview to 100%, and then the rest of the coloumns are displayed nicely, they have different widths. How do I set fixed with for SOME of the coloumns and leave the grid at 100%?
Regards,
ma se
|
|
|
|
|
i think you can set in headerstyle of grid view the width you want not sure you need to check it...
-- modified at 10:48 Tuesday 25th July, 2006
|
|
|
|
|
Hi,
I'm using my gridview to display my data. I have 2 properties, namely FirstName and LastName. How do I add both of these properties to a single cell?
Currently I have the FirstName displaued like this:
<asp:BoundField DataField="FirstName" HeaderText="Name">
<HeaderStyle CssClass="GridViewHeader" />
<ItemStyle CssClass="GridViewCell" />
</asp:BoundField>
It brings back only the name, I want it to bring back the first and last name and concatenate it as one, or should I just rather create a new property, something like Name?
Please help!!
Regards,
ma se
|
|
|
|
|
create a template column and add two labels to it. Add an event of itemdatabound and use the findcontrol method to apply the value.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
As Todd said, you can use the Template field in this case with or without two labels controls, and you can use the data binding expression instead of the RowDataBound event to bind data.
|
|
|
|
|
suppose two independent window called win1 and win2 is opened and there is no relation between
them.win2 is not open from win1 by javascript like window.open().suppose there is a button
in win2 called refresh and i want whenever some one will click on that button then win1 will
be refresh.is it possible if so plz help me with source code.
tbhattacharjee
|
|
|
|
|
If they are not related in any way, then i do not think that this is possible.
|
|
|
|
|
I want to give tooltip for each cell in Datagrid
For Ex:i wanna show tooltip like
a--in first row
b--in second row
Somewhat like this:
http://www.clarkescott.com/PermaLink,guid,5b4b123e-abbc-4e42-a377-8aebc0b045b0.aspx
In this example i mnot ableto get overlib file ---if any one has already downloaded the plz forward me
Any help
-- modified at 9:25 Tuesday 25th July, 2006
|
|
|
|
|
on ItemCreated event of the DataGrid for each item do this
e.Item.Cells[0].ToolTip = "a";
Nav.
|
|
|
|
|
If u can see i have done it already...i have specified a link Plz look there...i want like that
|
|
|
|
|
I am trying to export data to excel from a datagrid with paging enabled. But while executing an exception is being thrown - "Datagrid link button must be within a form tag with runat="server". This exception is probably due to the link buttons rendered for paging. Please help in this regard.
|
|
|
|
|
|
The CreateUserWizard is nice to use
and saves lots of hassles,
but problem is that when I register a user on my site,
it can't send through the confirmation email.
gmail returns the error message that it needs the connection to be SSL.
below is an extract from http://www.codeproject.com/useritems/SendMailUsingGmailAccount.asp
...
mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
...
but my send mail is not in a method,
how do i make the createUserWizard connect to the smtp with SSL activated?
Thank you
|
|
|
|
|
You can create a handler for the SendingMail event of the CreateUserWizard control, and provide your code to send the email in the way you want, you then have to cancel the event.
|
|
|
|
|
oicic,
never thought of that,
will try that
thanks a lot
|
|
|
|
|
Hi there!
I'm using a bound dropdownlist as a column in a gridview and using it's Control parameter in an update query.
//Here the GridView
<asp:GridView ID="GridView1" runat="server" DataKeyNames="price_id"
DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
AutoGenerateEditButton="true">
<Columns>
<asp:BoundField HeaderText="Room" DataField="room_number" />
<asp:BoundField HeaderText="Price ID" DataField="price_id"
ReadOnly="true" />
<asp:BoundField HeaderText="State" DataField="state" />
<asp:TemplateField HeaderText="RoomType">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1"
DataSourceID="SqlDataSource2" DataTextField="room_type"
DataValueField="price_id" SelectedValue='<%#Bind("price_id")%>'
runat="server">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="MySQL Connection String" ProviderName="System.Data.Odbc"
SelectCommand="SELECT room_number, price_id, state, expiry_date_if_occupied, comments FROM rooms;"
UpdateCommand="UPDATE rooms SET room_number=?, price_id=?, state=?, expiry_date_if_occupied=?, comments=? WHERE room_number=old_?;" OldValuesParameterFormatString="old_{0}">
<UpdateParameters>
<asp:Parameter Name="room_number" />
<asp:ControlParameter Name="price_id" ControlID="DropDownList1"
PropertyName="SelectedValue" />
<asp:Parameter Name="state" />
<asp:Parameter Name="comments" />
<asp:Parameter Name="room_number" />
</UpdateParameters>
</asp:SqlDataSource>
Problem 1
When I run, and try updating I get this exception: "Could not find control 'DropDownList1' in ControlParameter 'price_id'."
Please help me out with what's wrong with the code.
Problem 2
Note: The second BoundField column (Price_ID) binds to the same field as The DropDownList in the TemplateField.
Because of this, I would like to show the DropDownList only when in Edit mode. i.e The BoundField would be for Readonly mode and the DropDownlist for Edit mode.
Problem 3
Am I using the correct OldValuesParameterFormatString with the placeholder? NB: room_number is the key field
Thanks alot good People!
Live in fragments no longer. Only connect.
|
|
|
|
|
Prolem1:
You need to include the id of parent control of the dropdownlist (the GridView) in the ControlID of the ControlParameter. The UniqueId of the Dropdownlist can give you a hint.
Problem2:
It seems you state what you have done, but what is your problem? Is your problem that you currently have to use 2 columns for one field price_id? If you want to hide the bound field in the Edit mode, you can set the InsertVisible of the field to false . Another option is to use a label control in the ItemTemplate of the current Template field to display this value instead of using the bound field.
Problem3:
It's not correct:
+ .. WHERE room_number=?; ...
+ Use ConflictDetection="CompareAllValues"
+
...
<asp:Parameter Name="old_room_number" />
</UpdateParameters>
|
|
|
|
|
Hi there!
I'm having a problem with formating dates. I've tried to understand MSDN, but I never get it right.
First, I have this:
<asp:GridView ID="GridView1" runat="server"
DataKeyNames="reservation_id"
DataSourceID="SqlDataSource1"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Check in Date"
DataField="check_in_date"
DataFormatString="{0:yyyy/mm/dd}" ReadOnly="True" />
</Columns>
</asp:GridView>
I would like to change the format of the date bound to the above column into MySQL's yyyy/mm/dd (which I find a pain in the ***). The GridView displays
this date in MM/dd/yyyy format with the time attached e.g (8/30/2006 12:00:00 AM ->representing 30th August '06). MySQL accepts date as yyyy/mm/dd,
so I need to change the GridView's BoundField format but dont know how to do it.
Please help!
Note that OnRowUpdated event of the GridView, I use e.OldValues to get the date and use it in updating a related record in another table, that's why I need
the date in this format without the time.
Thanks a lot good people.
Live in fragments no longer. Only connect.
|
|
|
|