w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Export Gridview Data to Excel in ASP.NET Linq data bind
It's pretty easy to set up the excel export that will export only the gridview. This has been tested and will only export the gridview that appears on your given web page. For your C# code use the following: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class vxcel_export : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=file-name.xls"); Response.ContentType = "application/vnd.xlsx"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); Sys

Categories : Asp Net

Bind gridview using jquery : Have table data clickable
You are closing the anchor element in your code twice... <a href="#" onclick="getStock()" value=' + codes + ' />' + codes + '</a> Should be: <a href="#" onclick="getStock()" value=' + codes + '>' + codes + '</a> (note the removed "/" right before the anchor's greater-than character)

Categories : Javascript

sort and page result of data bind with eval by gridview
hi guys i did i did it by creating new sells and give them cssclass` int j = 0; protected void grid_advertise_1_RowDataBound(object sender, GridViewRowEventArgs e) { if (j<=1) { myConnection c = new myConnection(); SqlDataAdapter da = new SqlDataAdapter("select * from TblArticleWishka where ID>=0 ", c.Cnn); DataSet ds = new DataSet(); da.Fill(ds); int i = 1; foreach (DataRow dr in ds.Tables[0].Rows) { i++; TableCell a = new TableCell(); a.CssClass = "advertise_1_" + i + ""; a.Text = (string)dr["TitleEn"]; e.Row.Cells.Add(a); a.DataBind(); } j++; } }`

Categories : C#

Retrieve data from database and store in string and bind all the strings to gridview
You can loop through your DataTable returned from your stored procedure in the database, like this: // Iterate through the columns of the DataTable to set the BoundFields dynamically foreach (DataColumn theDataColumn in theDataTable.Columns) { // Instantiate new BoundField BoundField theBoundField = new BoundField(); // Set the DataField value theBoundField.DataField = theDataColumn.ColumnName; // Set the HeaderText value theBoundField.HeaderText = theDataColumn.ColumnName; // Add BoundField to the GridView GridView1.Columns.Add(theBoundField); }

Categories : Asp Net

GridView Dropdownlist CSS First letter should be black color and remaining content should be in green color
The CSS-selector for the first letter of an element is :first-letter. For example, make the first letter of a paragraph red p:first-letter { color: red; } I'm not familiar with applying CSS styles to GridView, but this site seems useful http://atashbahar.com/post/GridView-makeover-using-CSS.aspx edit: As I said, I am not familiar with GridView. However, in the example given on the webpage provided they use <asp:GridView ID="grdAvailableRooms" runat="server" CssClass="mGrid"> to assign a css class to the grid, and then in the css I guess you should do something like .mGrid ul li:first-letter { color: red; }

Categories : Asp Net

How to apply both cell color and alternating row color in aspx gridview at a time
I recommend you to use DevExpress css styles (instead of setting up properties of ASPxGridView) like this: .dxgvDataRow:hover { color: gray; } You can also use CssPostfix property of an ASPxGridView to set different styles for the control. For example: <dx:ASPxGridView ID="grid" runat="server" Styles-CssPostfix="MyGrid" ... would use following css: .dxgvDataRow_MyGrid:hover { color: gray; } To observe ASPx css class names just open a browser in development mode and look through the source code, you can find such classes: dxgvDataRowHover, dxgvFocusedRow, dxgvSelectedRow and many others. The advantage of such style customization is that html markup doesn't create style attribute for each of an html element, css editing is easier and faster and there's no need to cus

Categories : C#

display gridview data in another page or other gridview with row data in editable mode
You need to add RowCommand Event in GridView. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand"> <asp:LinkButton ID ="lnkEdit" runat ="server" CommandArgument='<%#Eval("Recordid")%>' CommandName ="cmdEdit" Text ='Edit'></asp:LinkButton> </asp:GridView> Here rocordid is the id of your record. In Page behind you need to write code. protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "cmdEdit") { string Recordid = Convert.ToString(e.CommandArgument.ToString()); Response.Redirect("EditPage.aspx?recordid="+Recordid ); } } On EditPage you can get recordid from the query string and can fetch the record form the datab

Categories : Asp Net

Gridview returning empty even when there is data. I want to use data in the gridview to update another database
Per my comment above you may want to do something like: List<string> _OrderIds = new List<string>(); DataTable table = gvOrderLines.DataSource as DataTable; foreach (GridViewRow gvr in table.Rows) { Label myOrderIDLablel = (Label)gvr.FindControl("lblOrderID"); //find control since it is a template field _OrderIds.Add(myOrderIDLablel.Text); } I hope this get you headed in the right direction.

Categories : C#

How to bind MembershipUsersCollection to GridView
The MembershipUserCollection implements IEnumerable but not IEnumerable so we have to cast the result and then transform that in a IQueryable: public IQueryable<System.Web.Security.MembershipUser> GridView1_GetData() { return Membership.GetAllUsers().Cast<MembershipUser>().AsQueryable<MembershipUser>(); }

Categories : C#

how to bind substring into gridview and
If you have an entity that you bind to your gridview, you can do this: First, add a new property: [NotMapped] public string CutDescription { get { if (Description.Length <= 1000) { return Description; } return Description.Substring(0, 1000) + "..."; } } Then you can bind this to your gridview: <asp:BoundField DataField="CutDescription" HeaderText="Description" /> This is just one way to do it. Hope it helps. EDIT: Another way using RowDatabound event: protected void Grid_RowDataBound(object sender, GridViewRowEventArgs e) { var row = e.Row; if (row.RowType == DataControlRowType.DataRow) { // Just change the index of the cell var description = row.Cells[1].Text; if (description.Len

Categories : Asp Net

How do we bind gridview with list of objects?
Do you expect your code fragment to be working and need help locating the problem, or are you asking how to code data binding and data aggregation in xaml/c# code? Your code is not complete and will not work. You need to perform an add operation to the list on button click which you can pull the input from text boxes. If you need the list data to reflect on to your xaml/display, you need to add notifier to trigger the UI to refresh on data change. You can learn how to do two way data binding properly from the Data-Binding sample code.

Categories : C#

Is this the correct way to bind a textbox to a gridview?
In-line SQL is not secure, you are vulnerable to SQL injection, because something extremely harmful to your database could be typed into that text box and there is not checking of that value. Read Understanding SQL Injection and Creating SQL Injection Proof ASP.NET Applications Use parameterized SQL or stored procedures inside of SQL Server.

Categories : Asp Net

WPF ListView-GridView : bind image
You can use a Data Binding ValueConverter for this Your converter class - public class MyImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string imageName = (string) value; return new BitmapImage(new Uri("../../images/" + imageName + ".png", UriKind.Relative)); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } In your code-behind foreach (KeyValuePair<string, string> Column in Columns) { GridViewColumn gvc = new GridViewColumn(); Binding binding = new Binding(Column.Key); if (Column.Key == "Image") {

Categories : C#

Bind a row of a grid to switch between a gridview and text
A very easy way to accomplish this is to overlay a grid on the GridView and only show if it the user is not logged in. You would take advantage of a BooleanToVisibilityValueConverter for this. <Grid Style="{StaticResource LayoutRootStyle}"> <Grid.Resources> <converters:BooleanToVisibilityConverter x:Key="BoolToVis"/> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="140"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <GridView x:Name="itemGridView" Grid.Row="2" ... /> <Grid Grid.Row="2" Background="Black" Visibility="{Binding IsLoggedIn, Converter={StaticResource BoolToVis}}"> <!-- The Grid control will fill the entire row

Categories : Wpf

MVC4 bind List of objects to ASP GridView
On the home page I would like to have several asp:GridView controls. Oops, there's no such notion as asp server side controls in ASP.NET MVC! You can forget about controls. ASP.NET MVC is an entirely different pattern. There's no such notion as ViewState and PostBacks, so server side controls simply cannot work in MVC. In ASP.NET MVC you could use helpers. For example the WebGrid helper is something that would allow you to build a grid. Here's an article on MSDN that illustrates the usage of this helper. I would also recommend you getting through the ASP.NET MVC getting started tutorials here and familiarize with the basic concepts.

Categories : Asp Net

c# - How to bind values from list in gridview rows?
foreach (string mon in Application["mondayValues"] as List<string>) { //Here is the problem foreach (GridViewRow row in gridActivity.Rows) { TextBox txtMon = (TextBox)row.FindControl("txtMon"); txtMon.Text = mon; } } In the above code you last value in the list Application["mondayValues"], is being assigned to all the text boxes txtMon because you are iterating all the rows and assigning them value, any change made in earlier iteration is being lost. This code to me is not making much of sense, can you include more details of what you are trying to to, so that we can look into the same.

Categories : C#

XAML GridView template bind to item
If Chapter is a DependencyProperty, then you can simply do: <local:ChapterBox Chapter="{Binding}" /> This will set the instance of the individual item to be bound to whatever Chapter is, obviously if the types don't match you can use a converter. Alternatively, you should probably look at simply setting the DataContext of the user control: <local:ChapterBox DataContext="{Binding}" ... />

Categories : C#

Why I can't bind a custom class to GridView as a group?
I had to make a similar control a while back. I used HeaderTemplates to display the header values in grid. Not sure if that will help you though. Code Example Something like this might work. <HeaderTemplate> <asp:Label ID="label" runat="server" Text='<%= Eval("text") %>' /> </HeaderTemplate> Code Behind To find the label in the gridview try this. Label lbl = (Label)gridview.FindControl('LabelId'); lbl.text = "your text";

Categories : C#

How to bind gridview at pageload with dropdown list
You should implement the RowCommand event from the GridView. You alredy have the CommandField, so do something like this: void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) { // // Get the keys from the selected row // LinkButton lnkBtn = (LinkButton)e.CommandSource; //the button GridViewRow myRow = (GridViewRow)lnkBtn.Parent.Parent; //the row GridView myGrid = (GridView)sender; // the gridview int reviewid = Convert.ToInt32(GridView1.DataKeys[myRow.RowIndex].Value); //value of the datakey **strong text** // If multiple buttons are used in a GridView control, use the // CommandName property to determine which button was clicked. // In this case you are pressing the button Select, as ou already // defined this at the aspx code. if(e.CommandNam

Categories : C#

How to bind CheckBoxes from GridView to source DataTable?
Here is how you can go about it, first assign an id to your checkboxes cbx.ID = "cbxDoTest. Then add a RowCommand event handler that will be triggered when your Validate tests button is clicked. Here you need to traverse the e.Row.Cells properties, if the cell belonged to a test column then do a search on the checkbox control (Checkbox cbx = e.Row.Cell[i].FindControl("cbxDoTest"); then check if the cbx.Checked is true or false. I wrote the flow and how to do it from my head so double check the method/property names.

Categories : C#

Bind images to GridView from database without using handler or httphandler
Is it possible? Yes. Is it a good idea? Not at all, and here's why. An HttpHandler is a way of providing a virtual URL for the image. This allows the browser to handle the GET requests on its own, in an order that's efficient, and asynchronously. This further means that the initial GET request isn't burdened down with conceivably MB's of images. The idea of a website is that it's more efficient to make a lot of smaller requests asynchronously than it is to make one massive request. Why? Because you're already at a disadvantage to provide the user with a good experience when disconnected from the server. Adding insult to that injury by making a massive request that could take minutes, isn't going to add to their joy.

Categories : C#

How to bind child objects of an object class to the GridView in ASP.NET?
You could easily use LINQ to flatten the expression, which is commonly a problem with binding to the gridview: var complaints = complaintManager.GetComplaints().Select((i) => new { i.ComplaintID, i.ComplaintRaiser.ComplaintRaiserID, . . }); This binds nicely to the grid. You could try dot notation in the markup as in ComplainRaiser.ComplaintRaiserID for a templated field with an eval (haven't had success with the BoundField myself...)

Categories : Asp Net

Select FirstOrDefault Value Bind to Gridview Window Form C#
try with below var query = (from b in doc.WireLine_Movements where b.CustomerInvoiceNo.Contains(txtCustomerInvoiceNo.Text.Trim()) orderby b.ID descending select new { b.AssetCode, b.CustomerInvoiceNo, b.CurrentLocation, b.FromLocation}).Take(1).ToList(); You can't Bind one item to grid view. create list from the item and set it as datasourse

Categories : C#

Bind an IEnumerable column inside a gridview templatefield
You should set up SelectedValue property of DropDownList. Intellisence does not show it up for some reason, but you can use it like this <asp:TemplateField HeaderText="Roles"> <ItemTemplate> <asp:DropDownList runat="server" SelectedValue='<%# Eval("Roles") %>'> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> But before binding it, you should full up DropDown with possible values. Manualy or using some datasource(I think ObjectDataSource will be good in your case)

Categories : C#

Bind Kendoui dropdownlist to mvvm data-bind value
Found the solution, here's the working code. @Html.Kendo().DropDownList().BindTo(new SelectList(ViewBag.HotelStatuses, "Id", "Name")).Name("ddl-hotel-status").HtmlAttributes(new Dictionary<string, object>{{"data-bind", "value: dataItem.HotelStatusId"}})

Categories : Kendo Ui

Bind GridView.ItemsSource back to DataTable but only visible columns and rows
if you want to have physical columns which are visible then you can directly iterate over datagrid columns collection like IEnumerable<DataGridColumn> visibleColumns = dataGrid.Columns.Where<DataGridColumn>(col => col.Visibility == System.Windows.Visibility.Visible); and then you can iterate over your DataTable records to get the value of field which has name equal to visibleColumn.Header.

Categories : Wpf

how to bind ASP.Net DropDownList control in EditItemTemplate of GridView on edit(imagebutton)click
protected void gv_RowDataBound(object sender, GridViewEditEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if ((e.Row.RowState & DataControlRowState.Edit) > 0) { DropDownList DStatusEdit= (DropDownList)e.Row.FindControl("DStatusEdit"); DataTable dt = con.GetData("select distinct status from directory"); DStatusEdit.DataSource = dt; DStatusEdit.DataTextField = "status"; DStatusEdit.DataValueField = "status"; DStatusEdit.DataBind(); DataRowView dr = e.Row.DataItem as DataRowView; DStatusEdit.SelectedValue = dr["columnname"].ToString(); } } } } protected void gv_RowEditing(object sender, GridViewEd

Categories : C#

Highlighting Gridview with Color
Please look at this link : http://www.c-sharpcorner.com/forums/thread/153329/changing-gridview-row-color-on-row-command.aspx Thanks, Hitesh

Categories : C#

Gridview onRowCommand fired gridview no data
Problem in this line ID = gvWorkshop.DataKeys[grdrow.RowIndex]["workshopID"].ToString(); You have mention "grdrow" in place of "row". please change it to ID = gvWorkshop.DataKeys[row.RowIndex]["workshopID"].ToString();

Categories : C#

Kendo UI Treeview data bind to XML: how does it bind to "id"?
Not sure if you got an answer for your question. This link http://demos.kendoui.com/web/treeview/remote-data.html will help you understand how your model data is bound to treeview. Please go through below links. HierarchicalDataSource - http://docs.kendoui.com/api/framework/hierarchicaldatasource DataSource - http://docs.kendoui.com/api/framework/datasource Model - http://docs.kendoui.com/api/framework/model For question #2, #3 Yes, it is possible to configure your model properties as below: schema: { model: { id: "EmployeeId", hasChildren: "HasEmployees", children: "EmployeeArray" } }

Categories : Kendo Ui

how to use substring in linq c# and also bind convert html tag in plan text. issue in binding GridView in asp.net
Did you try to add GetTextonly(v.Description) in your select? For this you need to name them to prevent the error of: Error Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access. This means that you need to name your anonymous type's properties that cannot be inferred. Check out this article as it will help you with Anonymous Types (C# Programming) var q = from v in con.View_tabel where v.Id == WeekId select new { name = v.Id, week = v.WeekId, day = v.DayId, titleText = v.Title,

Categories : C#

Changing color of selected row in asp.net gridview
GridViewRow is a control. Like every object on the page, it will be created during the page life cycle. The reference you hold in Session is to the object created during the last request. To solve the problem, keep only the index(or key) of the row in Session and use that to change the color of previous row. protected void btn_GrdClick(object sender, EventArgs e) { if(Session["PreviousRowIndex"] != null) { var previousRowIndex = (int)Session["PreviousRowIndex"]; GridViewRow PreviousRow = MyGridView.Rows[previousRowIndex]; PreviousRow.ForeColor = Color.White; } GridViewRow row = (GridViewRow)((Button)sender).NamingContainer; row.ForeColor = Color.Yellow; Session["PreviousRowIndex"] = row.RowIndex; }

Categories : C#

How to modify jQuery progressbar color in ASP.net gridview?
In your snippet the value in hidden field is the same as in the span for progress. So you rather use the same value to and make the decision of coloring. Updated: For e.g. you have let say two rows with value true and false <div class="progressbar"><span>70%</span></div> <div class="progressbar"><span>20%</span></div> <div class="status" style="visibility:hidden; height:0; width:0;">true</div> <div class="status" style="visibility:hidden; height:0; width:0;">false</div> Now you can read the value in each item and color them accordingly. var progressColorRed = "Red"; var progressColorGreen = "Green"; var progressBackColor = "lightYellow"; var progressLate = true; $('.progressbar').each(function(i

Categories : Javascript

How to change items color in gridview in android
In setOnItemClickListener() before starting the activity change the color of the currently clicked letter. When you'll return, the text should be pre-colored already. Something like this: gridView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { TextView currentLetter = (TextView) v.findViewById(R.id.grid_item_label); currentLetter.setTextColor(Color.GREEN); // start Activity2 here } } As a side note, provide implementations for the getItem() and getItemId() methods, otherwise you may get strange behaviours. @Override public Object getItem(int position) { return mobileValues[position]; //return the element from array at specified position } @Override publi

Categories : Android

Yii gridview change cell background color
Your css rules are being ignored. The selector that's being applied is table tr td thus yours should be as follows table tr td.notice { background:#FFF6BF; color:#514721; } If this doesn't work you could always set the rules using !important

Categories : CSS

How can I bind a custom color to WPF toolkit ColorPicker?
You must implement INotifyPropertyChanged And raise PropertyChanged event with the name of "Test" MSDN has an example INotifyPropertyChanged This allows WPF to be notified when your property changes

Categories : C#

Change color of selected cell in a gridview _RowCommand()
If this is a webpage(since you tagged asp.net) I would do it client sided, with javascript. Or else the page would be reloaded on-select and reselect. Add the cells to a class, and put an click event to them. Either changing the css background or adding them to a new class.

Categories : HTML

Bind Drawing.Color from settings with Style in XAML
As you would know that background property is of solidbrush type so its value can be set or get only with some solidbrush typw property . so what you can do is make a solidbrush type property in place of color like this..in your setting class. and now every thing just work fine.. static SolidColorBrush brush = new SolidColorBrush(Colors.Red); public static SolidColorBrush colorBrush { get { return brush; } } if you dont want to do that then you have to use value converter ..for that you can follow this link..hope it helps you..

Categories : C#

Change DevExpress GridView row back color after SetFocusedRowIndex(-1) by JavaScript
You can use the OnHtmlRowPrepared="gvMore_HtmlRowPrepared" on the aspx file at the ASPxGridview tag and implement it as follows on the cs file: public protected gvMore_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { e.Row.Attributes.Add("id",e.Row.RowIndex.ToString()); } On the client side you can then change the // ??? part with document.getElementById(ri).style.Background = "#122334" or whatever other color you might want. I have not executed the code, and there might be more ins and outs but that's the gist of it.

Categories : Javascript

Modifying jQuery progressbar's color based on Gridview column
Because of the extra white-space around the status the condition is not true.. You need to modify your code to trim the white space like this var status = $.trim( $(".status", this).text() ); Check this demo http://jsfiddle.net/aXTcV/1/

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.