How can I control the width of a column in the GridView control.

From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?

Here is the code:

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."
        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
        <Columns>
            <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
            <asp:BoundField DataField="item" HeaderText="item" SortExpression="item" />
            <asp:BoundField DataField="description" HeaderText="description" SortExpression="description" />
            <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
            <asp:BoundField DataField="image_url" HeaderText="image_url" SortExpression="image_url" />
            <asp:BoundField DataField="qty" HeaderText="qty" SortExpression="qty" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ChaosConnectionString1 %>"
        DeleteCommand="DELETE FROM [audio] WHERE [id] = @id" InsertCommand="INSERT INTO [audio] ([item], [description], [price], [image_url], [qty]) VALUES (@item, @description, @price, @image_url, @qty)"
        ProviderName="<%$ ConnectionStrings:ChaosConnectionString1.ProviderName %>" SelectCommand="SELECT [id], [item], [description], [price], [image_url], [qty] FROM [audio]"
        UpdateCommand="UPDATE [audio] SET [item] = @item, [description] = @description, [price] = @price, [image_url] = @image_url, [qty] = @qty WHERE [id] = @id">
        <InsertParameters>
            <asp:Parameter Name="item" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="image_url" Type="String" />
            <asp:Parameter Name="qty" Type="Int16" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="item" Type="String" />
            <asp:Parameter Name="description" Type="String" />
            <asp:Parameter Name="price" Type="Decimal" />
            <asp:Parameter Name="image_url" Type="String" />
            <asp:Parameter Name="qty" Type="Int16" />
            <asp:Parameter Name="id" Type="Int16" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int16" />
        </DeleteParameters>
    </asp:SqlDataSource>

 

Thank you in advance.
 

0
foolios
9/29/2007 3:04:42 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
969 Views

Similar Articles

[PageSpeed] 37

 I found that I needed to add a headerstyle tag to a asp:databound field tag.

So now my question is how do I make a row for an image drop below it's item row?

 The rows go straight across but I would like one row inbetween the first row of each item to display an item's picture:

http://foo.no-ip.org/images/dataviewhlp.gif 

0
foolios
9/29/2007 4:02:53 AM
Reply:

Similar Artilces:

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

can we use gridview control with in repeater control
HI all,     Can i use gridview control with in repeater control, Any one knows plzzz... let me know. Is there any possibility for this?      It is urgent required... plzzzz... help me..  ------------- ThanksBalu Chandaka  yes you can nest a gridview control in the repeater controlJeev~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~If you get the answer to your question, please mark it as the answer. Hi Jeev,    Thank you for your reply.But how can do that give some idea or If you have any example code snippet then plzzz... let m...

help me! WHY CAN THE TOP GRIDVIEW DETECT CONTROLS BUT THE SECOND GRIDVIEW NOT DETECT CONTROLS?!
Hi guys, two gridviews, same page, but one cant define paramters, the other one can.  the one that works is the first example, the one that doesnt work is the second example.  what is the difference? if you could highlight why example two doesnt detect contorls that would be great!!! example one <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2&qu...

Can I have a control that controls more than on link?
The question is, i have a page that have 3 sections that are controled by 3 controls.This controls just post to a page and then retrieve the html of the page and then post it back to the Community. This 3 contrlols have the same code except the link. of the page I want to retrieve . Is there a more simple way to not having 3 controls that due exactly the same? Thanks  ...

using controlS to control a gridview
This question is probably posted but i did not bother to look at 10,000+ posts so i am sorry. I've seen the tutorial where he builds a dataset and uses a gridview and controls the gridview with the drop down list box. What i am trying to do is to control the gridview with 2 drop down list boxes. First select the Country you life in and then the State. I've looked at the grid view properties but couldn't find where i can add another parameter. Is it possible to control a grid view (or any form of displaying the information) with more than 1 controller? Thank You.  ...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

Precise Control over GridView controls?
Hi.When you create a GridView in visual studios and bind it to, say, an SqlDataSource, it automatically creates fields and templates according to the types retrieved from the data source. (ie, it creates a Label for number/string columns, checkboxField for booleans, etc). My question: How do I control precisely what WebControls/Fields are used for each column?thanks,Tombow Hi Tombow Using TemplateFields you can control that explicitly.  See the Data Tutorial #12 at http://www.asp.net/learn/dataaccess/default.aspx?tabid=63 for more details. Hope that helps. AaronDon't...

SqlDataSource Control and Gridview control
Hi, I'm new to web development and learning about these controls.  The books teach you to bind the gridview control to an sqldatasource to perform delete,update,insert functions as well as to list the records in a table.  Is this standard practice for real world applications?  Or is there another way that should be used to display/manage table data in the gridview control? Thanks. Tulsi Using a sqldatasource is the best way I know of for binding data to a gridview.  (I'm pretty new to web development too, so maybe someone else can chime in if they know someth...

validation controls in gridview control
hi, I m using the grid view to add,edit,update,delete the data table. Everything is fine.In the footertemplate i get the values through text boxes and drop down lists.i took place sm validation controls to validate these controls.the problem arises here.if i want to update the record after i click the edit button, it validate the page n dont allow me to update the record.I want to validate the particular controls only. i checked if any causes validation property for update button.there is nothing like that. pls help me.. thanks in advance gowri  regards,gowripillaimark as answer if...

Is there a existing control or extender that can let radiobuttlist controls panels (or list of controls)?
Quite often, I need display a subset of controls on a form according to what user pick in a radiobuttonlist, for example, a radionbuttonlist with the following options 1, no 2, yes, email to me3, yes, mail to me when user pick 2, I need show please fill in your email : .... when user pick 3, I need showname :address :....... I can do this on server side, but it will cause page reload. Now I want to do it with Ajax, I want to know if someone has done some work on this, or there is something in Toolkit can do this thanks for help. These videos will get you going quickly: http://www.asp...

Trying to load a control into a control from another control
Exactly as the subject states, I'm trying to load a control into another control from a control loaded into a page, I keep getting this error from the code I have below. I've also tried the findcontrol but it keeps coming up null. (67): 'System.Web.UI.UserControl' denotes a 'class' where a 'variable' was expected UserControl ut = ((webcontrols.BrowseItems)UserControl).LoadControl("BrowseItems"); ((webcontrols.BrowseItems)UserControl).pnl_browse_main.Controls.Add(ut); This is how we Load User controls into a content place holder. try { UserCont...

Web resources about - How can I control the width of a column in the GridView control. - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 12/3/2015 6:12:25 PM