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>
Related
This is how I have my checkbox column currently:
<asp:TemplateField HeaderText="Hide/Show" ItemStyle-HorizontalAlign="Center" SortExpression="Hide_Show">
<ItemTemplate>
<asp:CheckBox ID="HideShowChk" runat="server" Checked='<%# Bind("Hide_Show") %>' />
</ItemTemplate>
</asp:TemplateField>
I have no code in my code behind because it's not necessary. Basically, a user can check or uncheck it, but it won't be reflected in the database unless I actually go into Edit mode, check or uncheck it, and then hit update so that the changes ARE reflected in the database.
Is there a way to have it so that the checkbox is "disabled" or anything of that sort while it's not in edit mode?
You have to use edititemtemplate for enabling it in the edit mode
<edititemtemplate>
<asp:CheckBox ID="HideShowChk" runat="server" Checked='<%# Bind("Hide_Show") %>' />
</edititemtemplate>
If you still want to use the check box inside the ItemTemplate make it disable using CSS or jQuery.
I have a web page built in .NET where I am a very simple DataGrid with several fields. I would like to have one of those field have its data placed in a TextBox so the user can edit the default description. Is there an easy way to do this by default so the user doesn't have to click an edit button for the row?
Yes, disable AutoGenerateColumns and define your own fields:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("Data") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Updating this data to the database might be more difficult though.
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.
i have used grid view to display data. Now i need to edit the row. I have kept edit link button in template field of grid-view. Now when i click the edit button, i need to retrieve the data for particular row into the server controls, so that user can enter the data into it.
How can i do that?
let me know if any info required..
thanks!
UPDATED
See http://img18.imageshack.us/i/editform.jpg/
Now, when i click edit from below grid, the data in grid should come up in above form.
There is a different template available in Gridview and you have to use it properly. For example, if you want to edit something, the editTemplate is available for that.. look at the following sample:
<asp:GridView runat="server" ID="grd">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="lbl"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="Textbox1"></asp:TextBox>
<asp:HiddenField runat="server" ID="hdf" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox runat="server" ID="Textbox1"></asp:TextBox>
<asp:HiddenField runat="server" ID="hdf" />
</InsertItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
have a look on these article
http://www.asp.net/data-access/tutorials/using-templatefields-in-the-gridview-control-cs
http://programming.top54u.com/post/ASP-Net-GridView-Edit-ItemTemplate-Mode.aspx
This is such a general question that you should really review how the GridView works in the first place.
Try reviewing the following example from MSDN regarding GridView editting;
http://msdn.microsoft.com/en-us/library/ms972948.aspx
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.