| | |
sqldatasourse and gridview
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
hii,,guys,,i m using asp.net2005 and sql server 2005...in my page i have used gridview and sql datasource,i m able to edit,update and delete the records,,the problem is tht for 1 column i would lik to use a dropdown list instead of textbox when i am in edit or update mode,,,heres is my code,,need help,,thnks in advance
ASP.NET Syntax (Toggle Plain Text)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sme_trackerConnectionString %>" SelectCommand="SELECT SME_Master.SME_Id, SME_Master.FirstName, SME_Master.LastName, SME_Master.Agency_id, SME_Master.Email, SME_Master.Address, SME_Master.Phone, SME_Master.Mobile, SME_Master.Fax, SME_Master.TimeZone_Id, SME_Master.Experience, SME_Master.City, SME_Master.State, SME_Master.Status, SME_Master.Level_Of_Exam, SME_Master.Other_Comments, SME_Master.Certificate, SME_Master.Expertise, Agency_Master.Agency_Name, SME_Master.Type_of_SME FROM SME_Master LEFT OUTER JOIN Agency_Master ON SME_Master.Agency_id = Agency_Master.Agency_Id" OnSelected="SqlDataSource1_Selected" InsertCommand="INSERT INTO [SME_Master] ([SME_Id], [FirstName], [LastName], [Type_of_SME], [Agency_id], [Email], [Address], [Phone], [Mobile], [Fax], [TimeZone_Id], [Experience], [City], [State], [Status], [Level_Of_Exam], [Other_Comments], [Certificate], [Expertise]) VALUES (@SME_Id, @FirstName, @LastName, @Type_of_SME, @Agency_id, @Email, @Address, @Phone, @Mobile, @Fax, @TimeZone_Id, @Experience, @City, @State, @Status, @Level_Of_Exam, @Other_Comments, @Certificate, @Expertise)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE SME_Master SET FirstName = @FirstName, LastName = @LastName, Type_of_SME = @Type_of_SME, Email = @Email, Address = @Address, Phone = @Phone, Mobile = @Mobile, Fax = @Fax, Experience = @Experience, City = @City, State = @State, Agency_Master.Agency_Name = @Agency_Name FROM SME_Master INNER JOIN Agency_Master ON SME_Master.Agency_id = Agency_Master.Agency_Id WHERE (SME_Master.SME_Id = @original_SME_Id)" DeleteCommand="DELETE FROM SME_Master where SME_Id=@original_SME_Id" >
Johnny.G
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 118
If i were you, i would use the grid view for selecting and use formview for updating. Formview is more flexible. You can insert dropdownlist to its edititemtemplate, read the entry in my blog http://www.daniweb.com/blogs/entry2043.html
Due to lack of freedom of speech, i no longer post on this website.
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
•
•
•
•
If i were you, i would use the grid view for selecting and use formview for updating. Formview is more flexible. You can insert dropdownlist to its edititemtemplate, read the entry in my blog http://www.daniweb.com/blogs/entry2043.html
ASP.NET Syntax (Toggle Plain Text)
UPDATE SME_Master SET FirstName = @FirstName, LastName = @LastName, Type_of_SME = @Type_of_SME, Email = @Email, Address = @Address, Phone = @Phone, Mobile = @Mobile, Fax = @Fax, Experience = @Experience, City = @City, State = @State FROM SME_Master INNER JOIN Agency_Master ON SME_Master.Agency_id = Agency_Master.Agency_Id WHERE (SME_Master.SME_Id = @original_SME_Id)
Johnny.G
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
welll now thrs a small change,,,,forget updating two tables,,,,sorry for tht,,what i m thinkin of is tht on updating the agency name(which is in the Agency_Master table),,,the particular agency_id (which is in SME_Master table)should change,,,in short i am updating the Agency_id,,,,,,,coz it is far more sensible to change the id on selecting the agency name,,,but the other prob still remains the same,,in edit mode the dropdown list should display the default value which is different for diff rows...how can i do tht..pls reply asap..thnks in advance
Johnny.G
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 118
First you need to set the gridview's autogeneratecolumns property to false then create template fileds under the columns section of the gridview :
<Columns>
<asp:TemplateField>
<ItemTemplate>
your normal controls go here
</ItemTemplate>
<EditItemTemplate>
your dropdown goes here
</EditItemTemplate>
</asp:TemplateField>
<Columns>
<asp:TemplateField>
<ItemTemplate>
your normal controls go here
</ItemTemplate>
<EditItemTemplate>
your dropdown goes here
</EditItemTemplate>
</asp:TemplateField>
Last edited by serkan sendur; Mar 4th, 2008 at 6:45 am.
Due to lack of freedom of speech, i no longer post on this website.
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
•
•
•
•
First you need to set the gridview's autogeneratecolumns property to false then create template fileds under the columns section of the gridview :
<Columns>
<asp:TemplateField>
<ItemTemplate>
your normal controls go here
</ItemTemplate>
<EditItemTemplate>
your dropdown goes here
</EditItemTemplate>
</asp:TemplateField>
Johnny.G
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
•
•
•
•
First you need to set the gridview's autogeneratecolumns property to false then create template fileds under the columns section of the gridview :
<Columns>
<asp:TemplateField>
<ItemTemplate>
your normal controls go here
</ItemTemplate>
<EditItemTemplate>
your dropdown goes here
</EditItemTemplate>
</asp:TemplateField>
need ur help,,thnks in advance
Johnny.G
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Problem on calling a javascript in a class
- Next Thread: Running both ASP.NET 1.1.4 and ASP.NET 2.0 on IIS 5.1
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers






