Last post Jan 14, 2008 08:03 PM by vinz
Jan 13, 2008 04:23 PM|tomngi|LINK
I want to create a 2 column grid on my webpage. The first column is data selected from a table in SQLServer 2005. The second column, however, is data to be entered by the user corresponding to the text prompt
in column 1 of the same row, i.e. the second column does not come from the database, but will be used to update it from C# code. I have in mind the user clicking a "submit" button when he is done entering data.
Question: how do I create the grid and populate it so that when the query executes only column 1 will be populated, while column 2 will be left empty and editable?
I am sure this is simple for someone who knows GridView well. Any hints appreciated. If this is difficult to do any alternative suggestions?
Jan 13, 2008 06:14 PM|leoalves|LINK
Well I didnt quite understand what you are trying to do.
You should have both collumns in the database. Otherwise it wont work.
You have to use the gridview with both collumns and the first one you set the propertie as readonly. Your gridview will list all the itens in the database and will have an edit button, when the user clicks this button wil enable editing only the second field:
The could should be something like:
DataField="NamePK of your database"
DataField="NameCollumn in database"
Jan 13, 2008 08:56 PM|vinz|LINK
You can use BounFields column to display the data in the grid from you Database and use Template Fields in the second column wherein a user can inputs a data
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ShowFooter="True" >
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="FieldName" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button23" runat="server" Text="Button Submit Footer" />
After the Button Submit on the footer will triggered then just clear the all the input in TextBox1...
Hope my suggestion helps
Jan 14, 2008 04:30 PM|tomngi|LINK
Hi, that worked fine! Pretty much exactly what I wanted.
Jan 14, 2008 08:03 PM|vinz|LINK
You're welcome.. BTW if your issue was resolved then dont forget to mark helpful post as an answer so that others who have the same problem as you can easily find those helpful post... [:D]