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

How to return SQL DataReader data
Rather than returning the data reader add all of the values to a collection. Here you'll want a List<T> or T[] (array). This should contain objects that model the results of your query. If you're only returning the Guids then it would be List<Guid> or Guid[]. In general, all of your db interactions should be in one layer of the application. It's at that point that you want to deserialize query results. Elsewhere in your code you should deal with native C# types rather than a query result that is still pending deserialization. Here you generally just want methods that take whatever data is necessary to form a query and return an object or a collection of objects which model the query results.

Categories : C#

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#

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

how to compare oledb datareader with a textbox data?
You are trying to compare the actual OleDbDataReader object with the TextBox string value, which will obviously not return true ever. You need to compare the column value of your query with the text box. You might also consider putting a WHERE clause in your sql to filter out unnecessary rows. Please read this article to get a basic understanding of how to perform data access with MS Access - http://msdn.microsoft.com/en-us/library/ms971485.aspx if ((string) reader["[mobile_no]") == textbox7.Text) { // error {

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 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 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#

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#

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

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#

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

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#

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#

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#

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 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#

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

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#

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

Bind failed with Invalid argument error
bind (monsocket, (struct sockaddr *) &name, sizeof (name)) Your sizeof(name) yields the size of the generic sockaddr_storage size. You need the size of sockaddr_in or sockaddr_in6. In any case, you'd be better of by just using the stuff from getaddrinfo directly: monsocket = socket(res->ai_family, res->ai_socktype, res->ai_protocol); bind(monsocket, res->ai_addr, res->ai_addrlen); In order to do that you'll have to move your freeaddrinfo(res) call.

Categories : Sockets

Failed to bind radio buttons to view
You can do this by defining a view App.TestView = Ember.View.extend({ classNameBindings : ['active'], attributeBindings : ["value"], click : function() { this.set("selection", this.get('value')) }, active : function() { return this.get("value") == this.get("selection"); }.property('selection') }); Here is your Fiddle Hope it helps..

Categories : Ember Js

nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Skype uses port 80,443 by default, those are EXACTLY the http and https ports. Try shutting down skype and restarting nginx. If you are using the 'desktop version' of Skype you can change this setting by the way of tools>options>advanced>connections > untick use port 80 and 443 as alternatives. If you are using the win8 app, the only option seems to be shutting down skype completely or removing it completely. Someone has to confirm the win8 app though, I use linux.

Categories : PHP

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#

Failed to bind to $PORT when trying to deploy Python/flask app to Heroku
if you look at this page https://devcenter.heroku.com/articles/dynos (search for "web dynos") you see that Heroku sets the environment variable $PORT So, even if you can't specify the port Flask will run on, you can at least know it from the $PORT variable.

Categories : Javascript

(ubuntu) nginx: [emerg] bind() to 0.0.0.0:80 failed (13: permission denied)
the socket API bind() to a port less than 1024, such as 80 as your title mentioned, need root access. here is "Bind to ports less than 1024 without root access" and another easier way is to run nginx as root.

Categories : Nginx

how to bind check box values on gridview with the values of database table?
ASPX: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="ID"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("id") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Staff"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Eval("staff") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> Code behind: protected void Button1_Cl

Categories : C#

YouTube Data API failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
is file_get_contents supported on your web server? many web servers dont support this function due to security risks. have you looked into using curl instead? maybe something like this: $option = array( 'part' => 'snippet', 'q' => 'search_query', 'type' => 'video', 'key' => 'your_key' ); $url = "https://www.googleapis.com/youtube/v3/search?".http_build_query($option, 'a', '&'); $curl = curl_init($url); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, false); $json_response = curl_exec($curl); curl_close($curl); $responseObj = json_decode($json_response);

Categories : PHP

ASP.Net object reference error when writing data to xml file via Gridview Empty data template
The issue is when you have the xml file without 'po' node. You can move the node to a new method like: Private Function CreatePOSDataset() As DataSet Dim oDs As New DataSet() oDs.DataSetName = "newshipmentnotification" oDs.Tables.Add("pos") oDs.Tables("pos").Columns.Add("pos_Id") oDs.Tables("pos").Columns("pos_Id").ColumnMapping = MappingType.Hidden oDs.Tables.Add("po") oDs.Tables("po").Columns.Add("ponumberID") oDs.Tables("po").Columns.Add("pos_Id") oDs.Tables("po").Columns("pos_Id").ColumnMapping = MappingType.Hidden oDs.Tables("po").Columns.Add("ponumber") Dim pos_po As DataRelation = oDs.Relations.Add("pos_po", oDs.Tables("pos").Columns("pos_Id"), _ oDs.Tables("po").Columns("pos_Id"))

Categories : Asp Net

should reassigning my viewmodel clear ui data in
It is a little hard to tell without knowing what your presenter is doing, but in general you will want to avoid calling ko.applyBindings on content that has already been bound. If you are trying to load a new propertyModel into your view, then it generally helps to use either the with or template binding against an observable like: <div data-bind="with: currentPropertyModel"> ...content here </div> Then, you define a currentPropertyModel as an observable, call applyBindings a single time, and then just set and clear currentPropertyModel with the model that you want rendered. When you clear it, the content will be removed and when you set it to a new one, then it will be rendered with that new model as the context.

Categories : Knockout Js

MS Office - How bind some parts of document to custom XML data and then replace this data via .NET?
There is support for repeating content controls in Word 2013 (Target namespace: http://schemas.microsoft.com/office/word/2012/wordml); see repeatingSection in [MS-DOCX] For approaches which don't require Word 2013, Google "repeatingSection openxml sdk" or some such. As a solution to this problem, I documented a standardised approach, and named it OpenDoPE. You can build your own support for this way of doing it using the OpenXML SDK, or you could IKVM docx4j. In essence, you need to create the table rows, and in each, make a content control bound to the corresponding entries in your collection.

Categories : C#



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