Adding check box to grid view for each row - asp.net

I am filling a GridView with the data table but on each row I want a check box how can I achieve this?

<Columns>
<asp:TemplateField HeaderText="Select" HeaderStyle-HorizontalAlign="Left">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked="false" />
</ItemTemplate>
</asp:TemplateField>
Use this, you will find what you want!

You could use a < asp:TemplateColumn > or, depending on your desired functionality, opt for a repeater control instead.

Right click the grid view and add a template column. Inside that column, you are able to put whatever you want - including a checkbox.

Related

How to make checkbox editable in aspxgridview?

I need multiple selection of rows in a grid. I have done 1 with the selection command column, now I have inserted another check column, can anyone tell me how to make that column editable without using edit button? I am using DevExpress ASPxGridView Control.
If I understand correctly you can add a ItemTemplate under Columns like this
<asp:TemplateField HeaderText="fieldname">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<ItemTemplate>
<asp:CheckBox Text="text" Checked="false" AutoPostBack="true" runat="server" />
</ItemTemplate>

ASP.NET: How to re-flow GridView cells over multiple lines

I have an application which contains a table with two columns: messageid and messageDesc . Inside the messageDesc column there is a message description. When I try to bind the GridView to the messageDesc column, it renders the entire column on a single line, requiring the user to scroll horizontally to view the complete text. I want to prevent this by having the description flow over multiple lines. How do I do this?
I have tried using the ItemStyle attribute but it's not working. Please suggest a solution. In addition to this, I can't change the database message content.
Thanks in advance.
Warp label insdie div element and than try out this will surely work for you
<asp:TemplateField>
<ItemTemplate>
<div style="width:100px;">
<asp:Label ID="Label2" runat="server" Text="<%# Eval("description") %>"></asp:Label>
</div>
</ItemTemplate>
</asp:TemplateField>
or
<ItemStyle Wrap="true" Width="100px" />
You can display data in textbox using template field instead of bound field. See below, textbox code. Your TemplateField would look like this:
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" Text='<%# Eval("MessageDesc") %>'
TextMode="MultiLine"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
The ReadOnly setting keeps users from editing the data while having it still enabled for them. In Edit mode, of course you would set ReadOnly to false.

Interacting with rad grid? How to declare the custom columns?

In web application[asp.net], i am using telerik grid control, i am bind the data to grid when it is autocompletecolumns=true, now i want to bind the data autogeneratecolumns=false how can i place controls like in asp.net grid we use
<columns><asp:Templatefileds><ItemTemplate><asp:label id ="lblid" runat="Server"
Text='<%# Eval("Empid") #> /></ItemTemplage></asp:templae>
Radgrid also have template column like ASP gridview, you can use template columns as:
<MasterTableView ShowFooter="False">
<Columns>
<telerik:GridTemplateColumn UniqueName="TemplateColumn" SortExpression="CompanyName">
<ItemTemplate>
// Your Logic Here
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
Hope this helps.
When the columns are not autocompleted, you must specify them as tags inside your Columns tag. You must specify the attributes for the tags which denote your columns and in the NeedDatasource event you fill your datasource.

SPGridView Filter menu shown separated of LinkButton with templated header

I use Microsoft.SharePoint.WebControls.SPGridView control to write out data.
Filtering is allowed for grid.
Columns contain templated column, it define ItemTemplate and HeaderTemplate:
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:LinkButton ID="linkTitleHeader" runat="server" Text="TitleHeader1"
CommandName="Sort" CommandArgument="Title"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
some text
</ItemTemplate>
</asp:TemplateField>
</Columns>
It works fine, shows header as link, its performs sorting by click, but filter menu
show on separate row:
i expect that it shows as:
I already try with no result:
Leave Text property empty and define other properties
Set Microsoft.Sharepoint.WebControls.Menu Text programmaticaly after
databind
Set link text by javascript
Have any ideas how to join Menu with LinkButton ? Thanks.
You must also specify the properties of SPGridView : FilterDataFields, FilteredDataSourcePropertyName, FilteredDataSourcePropertyFormat. Maybe this article will help you link

How to display a large amount of data in gridview

I am trying to show a large amount of data in gridview but the problem is that everytime data increase the gridview row size increase automatically.
is there any possible way that the data which is stored in my MS access Database display in multi line instead of one single long line.
If you are populating the GridView using AutoGenerate="true" make if AutoGenerate="false"
Then use asp:TemplateField to populate the GridView.
Now give an ItemStyle-Width and ItemStyle-Wrap.
<asp:TemplateField ItemStyle-Width="50px" ItemStyle-Wrap="true">
<ItemTemplate>
<asp:Label ID="ShipNameLabel" runat="server" Text='<%# Eval("ShipName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
The telerik gridview control supports multi line rows http://www.telerik.com/products/aspnet-ajax/grid.aspx.
However, this does cost. You may try displaying only a few columns, then the user has to click on the row to see the other information in a form view.
Don't understand your question fully but it sounds as a Repeater might work better for you where you have more control of the layout of the rendering.
If it is the amount of rows that are the problem I do recommend to introduce paging to limit amount of row displayed at once.
Update:
1) Set up a CssClass for the GridView itself and include the table-layout:fixed style. This tells the browser that you're going to specify the width of each cell. You may also want to include the overall width of the grid here as I mention in (3).
2) The first row of the table sets the width for each cell, and that's usually the HEADER row, not the item row, so use either HeaderStyle-CssClass or HeaderStyle-Width to set the width of the cell.
3) Make certain the table itself is wide enough to hold all of the cells. I added up all of my cell widths and used that to set the width via the CssClass attribute on the GridView.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns='false'>
<Columns>
<asp:BoundField DataField='Name' />
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat='server' ReadOnly="true" BorderStyle="None"
TextMode="MultiLine" Text='<%# Bind("Description") %>'
>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
You may have to add some styling to gridview via .skin or css

Resources