Telerik RadGrid Culture setting not working - c#

I was expecting that the property Culture of the radgrid can be used to set the culture of the grid and this reflect also the data displayed in its cells, right?
But in this Grid:
<telerik:RadGrid ID="GrdWaypoints" runat="server" Width="550px" AutoGenerateColumns="False" Culture="en-US"
AllowAutomaticUpdates="false" AllowAutomaticInserts="false"AllowAutomaticDeletes="false"
OnDeleteCommand="GrdWaypoints_DeleteCommand"OnInsertCommand="GrdWaypoints_InsertCommand" OnUpdateCommand="GrdWaypoints_UpdateCommand"OnItemDataBound="GrdWaypoints_ItemDataBound"
GroupPanelPosition="Top" OnNeedDataSource="GrdWaypoints_NeedDataSource">
<ClientSettings AllowDragToGroup="false">
<Scrolling AllowScroll="false" UseStaticHeaders="false" />
</ClientSettings>
<GroupingSettings ShowUnGroupButton="false" />
<MasterTableView ShowGroupFooter="False" Width="100%" DataKeyNames="WaypointID"EditMode="InPlace">
<Columns>
<telerik:GridNumericColumn UniqueName="Longitude" HeaderText="Longitudine"DataField="Longitude" DecimalDigits="6" DataFormatString="{0:#0.000#}" ></telerik:GridNumericColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
... no matter what I specify in the culture property, the numbers, in the longitude GridNumeric column, are always displayed based on the number format specified in the regional settings of the server.
And obviously, on the Insert and Update command, everything goes in error if the user types the number in a different culture from the server.
Does anyone know a workaround for this bug?

Related

Delete row from aspnet gridView via column button

I want to delete a row from an aspnet table, that have columnButton with [delete] button.
This is my code:
<asp:GridView ID="GridInduccionPersona" runat="server" EnablePartialRendering="true" AutoGenerateColumns="False" DataKeyNames="RUT" CellPadding="4" ForeColor="#333333" GridLines="None" DeleteMethod="GridInduccionPersona_RowDeleting">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="RUT" HeaderText="Rut" InsertVisible="False"
.
.
.
**<asp:ButtonField ButtonType="Button" CommandName="Delete" HeaderText="Eliminar" ShowHeader="True" Text="Eliminar" />**
</Columns>
</asp:GridView>
but when I put the page on Chrome; said: The Select operation is not supported unless you specify SelectMethod.
I just want to acces to function in server, and delete from gridview and database.
I dont want to use linq or similar, Im working with stored procedure.
Any idea about that ? is SelectMethod important for delete from my column ? (I supposed that the button call the id, or some similar in gridview to delete)
From what I remember from ASP.net Webforms, the GridView needs the SelectMethod property configured to works properly.
SelectMethod should point to the method that obtains the records.
Without this property, GridView can't list the records, so you can't delete them.
So, set the SelectMethod property to target to the method that retrieves the records.

How to display alternative color in datagridview if it is empty?

The Alternative BackColor property works if there is data in datagridview . I want to show Alternative BackColorif it is empty.
When declaring your GridView, you can configure options in the EmptyDataRowStyle and the EmptyDataRowStyle elements. So I suppose you can assign the same value to the BackColor in both EmptyDataRowStyle and AlternatingRowStyle elements like in the sample below.
<asp:GridView runat="server" ID="myGridView">
<EmptyDataTemplate>No data</EmptyDataTemplate>
<EmptyDataRowStyle BackColor="Red" />
<AlternatingRowStyle BackColor="Red" />
</asp:GridView>

ASP.NET set GridView update to CausesValidation = "false"

As the title suggests, I am attempting to set the UpdateMehod of a GridView to false. When the Update buttons is currently clicked, the event fires validation of a separate control, even though the separate control is in a separate validation group. The grid view is shown below:
<asp:GridView ID="BikesItems"
runat="server"
CssClass="table table-hover"
ItemType="WLL.DAL.Bike"
DataKeyNames="BikeID"
SelectMethod="BikesItems_GetData"
UpdateMethod="BikesItems_UpdateItem"
DeleteMethod="BikesItems_DeleteItem"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"
AutoGenerateColumns="false"
ValidationGroup="BikeGrid">
<Columns>
<asp:DynamicField DataField="BikeID" />
<asp:DynamicField DataField="BikeName" />
<asp:DynamicField DataField="Description" />
<asp:DynamicField DataField="ImgPath" />
<asp:DynamicField DataField="Price" />
<asp:DynamicField DataField="ManufacturerID" />
</Columns>
</asp:GridView>
How do I set the CausesValidation to false for the update button, bearing in mind it is dynamically generated? Or does a more elegant solution exist? Thanks
If you just wish to disable the validation group in the code behind (server-side), Use Page.GetValidators("ValidationGroup") method. You can pass in the name of the ValidationGroup and the method returns a ValidatorCollection over which you can iterate.
Or ClientSide, you can iterate over the Page_Validators array and check each validator group name that matches the group you're looking for and disable each as needed.

ASP.Net GridView - Show the last 4 digits

In my gridview, I have a column that I need everything masked but the last 4-digits.
This is my GridView:
<asp:GridView ID="GridView" runat="server" AutoGenerateColumns="False" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="br_id" DataSourceID="SqlDataSource6">
<Columns>
<asp:BoundField DataField="AccountNumber" HeaderText="Account Number" SortExpression="AccountNumber" />
</Columns>
</asp:GridView>
I tried the Right function of SQL Server in my SQLDataSource,
`SELECT '****-****-****' + RIGHT (AccountNumber, 4)` FROM....
the issue then is, when I hit edit, and save in my GridView, it will save this in the database, for example: ****-****-****-1234
Return 4 digits from the database. Only update the the account number in the database if you edit the account number.
If the users need to be able to see the full account number then it defeats the purpose of masking it in the first place.

store image in database and retrieve in datagridview

I am trying out new things myself in .net.I want to store image url in database and retrieve it dynamically in gridview.I have tried using blob.But i do not want to store image in database but just the urls.Some solutions that i have found that we can use template field in gridview and somehow use bind function.Also I can store all images in project folder and retrieve the images from folder.On button click i want to display images in gridview.But still i am not able to proceed forward.This is my code so far....
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Model_Id" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="Model_Id" HeaderText="Model_Id"
InsertVisible="False" ReadOnly="True" SortExpression="Model_Id" />
<asp:BoundField DataField="Model_Name" HeaderText="Model_Name"
SortExpression="Model_Name" />
<asp:BoundField DataField="Max_seats" HeaderText="Max_seats"
SortExpression="Max_seats" />
<asp:BoundField DataField="Image" HeaderText="Image" SortExpression="Image" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [Model]"></asp:SqlDataSource>
</div>
inside your GridView add a template field i.e.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Model_Id" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField HeaderText="Photo">
<ItemTemplate>
<img src='<%# Eval("Image") %>' />
</ItemTemplate>
</asp:TemplateField>
//other bound columns
</Columns>
</asp:GridView>
where Image is the column inside your table [Model], containing Image URL.
if Images don't show, check the relative url structure, you might need to prefix/adjust it like this:
/images/image1.jpg to ../images/image1.jpg (depends on relative location of your folder containing images)
it should work for you.
store the images in a folder in solution explorer of your project, if you want to save the link to the database then set the data type of the coloumn to varchar(MAX) and store the link of the image to database table like below.
1.If your folder name is Image, then store the url as ../Image/picture.jpg
2.go to quick task menu of the gridview and click edit fields and from the AVAILABLE FIELDS list choose "ImageField" and click add, the image field is then added to SELECTED FIELDS
3.move the "ImageField" in SELECTED FIELDS up or down to place it between other columns
4.Click the "ImageField" and ImageField properties will be displayed on the right side, GOTO
DATA and in "DataImageUrlField" select the Database table column name from where you want to retrieve the image .
Thats Should Work, ImageField will automatically generate the HTML code for your images to be displayed.

Categories