2 DropdownLists 1 SQLDataSource

Jan 19, 2007

I have 2 dropdownlists that use different fields from 1 SQLDatasource. I want one of the dropdown's to be a main dropdown that users will see, the other will be invisible. When a user changes the main dropdown and it does a postback, I want the second to also go to the record that the main one is on.
The reason being is that I have a lot of SQLDatasource's on one page, most of them take an ID parameter but some SQLDatasource's need a CODE parameter. I can't think of any other way to parse the code parameter. I want to use a control parameter for the SQLDatasource's to pass the CODE from the invisible dropdown but obviously I need it to go to that record when the main dropdown changes

View 2 Replies


ADVERTISEMENT

Using One SqlDataSource For Many DropDownLists, But Ability To Set Parameters?

Jan 3, 2007

If I have a lot of dropdowns of similar type but only differ in one field, is there a way to set parameters so that the dropdownlist can specify what the parameter values are?
 For example dropdowns: expenseaccount, incomeaccount, assetaccount
SqlDataSource:
SelectCommand="select accountid,accountname from accounts, accounttypest where accounts.accounttypeid=acounttypes.accounttypeid and accounttypes.accounttypename=? order by accountname"
<SelectParameters>
<asp:Parameter Name="accountTypeName" Type="string" />
</SelectParameters>
 -------
I would like expenseaccount to be able to specify "EXPENSE", incomeaccount to specify "INCOME", etc...
 Or is sqldatasource reusage bad practice?
(damn vs2k5 colors)

View 7 Replies View Related

How To Bind Data Retrived From Sql Db To DropDownLists?

Jun 20, 2007

 Hello all,I just have problems to bind the data to dropdownlists, and my code is written as:  SqlConnection myConnection;            SqlCommand myCommand;            SqlDataReader myReader;            myConnection = new SqlConnection();            myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["NorthWindConnectionString"].ConnectionString;            myCommand = new SqlCommand();            myCommand.CommandText = "select PostalCode from Customers order by PostalCode asc";            myCommand.CommandType = CommandType.Text;            myCommand.Connection = myConnection;            myCommand.Connection.Open();            myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);            DropDownList1.DataSource = myReader;            DropDownList1.DataBind();            myCommand.Dispose();            myConnection.Dispose();Any idea? Thanks 

View 3 Replies View Related

Can Save Labels To The DB But Not The Content Of DropDownLists !

Jul 28, 2007

hi there, i have a payment page which uses javascript to calculate payments and what remains etc. That all works fine, the problem i have is that when you are finished and you go to the next page it should save all of the records to the order table where the order_id = a querystring. Now i have tried using an insert method and an update method, not really sure whats the difference when putting data into an existing record. What happens though is that i can save the contents of labels etc but it wont save the content of dropdown lists (of which there are 2) i just cant work it out, i have posted my code below
 string strOrderID = Convert.ToString(Request.QueryString["OrderID"]);
string strDiscountPercent = Convert.ToString(5656);double dblDiscountMoney = Convert.ToDouble(txtDiscountMoney.Text);
string strPaymentMethod1 = ddlPaymentMethod1.SelectedValue;double dblPaymentAmount1 = Convert.ToDouble(txtPaymentAmount1.Text);
string strPaymentRecipt1 = txtPaymentRecipt1.Text;string strPaymentMethod2 = ddlPaymentMethod2.SelectedValue;
double dblPaymentAmount2 = Convert.ToDouble(txtPaymentAmount2.Text);string strPaymentRecipt2 = txtPaymentRecipt2.Text;
 string sConnectionStringCustInfo = "my connection string";
SqlConnection objConnOID = new SqlConnection(sConnectionStringCustInfo);
//This is the sql statement.using (objConnOID)
{
objConnOID.Open();
 string sqlUpDate = "UPDATE tbl_order SET discount_Percent = " + txtDiscountPercent.Text +
", discount_money = " + dblDiscountMoney + ", payment_method1 = " + strPaymentMethod1 +   =========== this is the problem line here!
", payment_amount1 = " + dblPaymentAmount1 + ", payment_ref1 = " + strPaymentRecipt1 +
", payment_amount2 = " + dblPaymentAmount2 +", payment_ref2 = " + strPaymentRecipt2 +
 
"WHERE order_ID = " + strOrderID;
 
 
 
SqlCommand objCmd1 = new SqlCommand(sqlUpDate, objConnOID);
 
try
{
 
objCmd1.ExecuteNonQuery();
}
 
and because it throws an error it wont update the database with any other record. does anyone have any ideas, i have spent hours last night trying to figure this one out and im sure its simple! but i need some help!
 
Cheers
Jez

View 5 Replies View Related

SQL Query Help - Using DropDownLists To Sort (multiple Variants)

Mar 15, 2007

Hi Everyone,I am creating a portal and want the user to be able to select four variants from four separate drop down boxes... Such as chapter, story, etc... The user will then be able to click Find and shorten up the gridview list. The below query is what I am using for my current gridview (with custom paging). What I want to do is something like this: Pass a variable such as @Story. If no Story is chosen, then the variable would be *. If a variable is chosen, the the @Story would the StoryID. However, I don't believe SQL recognizes the * in this case. I was thinking it should, but I don't believe it does. I was hoping it would just take it and I could write, SELECT * from Stories where StoryId=@Story, or something like that... and if * was @Story, then it would just select all... or if it was 1, then just stories with a StoryId of 1.Am I totally off base here? Thanks!  CREATE PROCEDURE SortAllStories@startRowIndex int,@maximumRows int,@totalRows int OUTPUTASDECLARE @first_id int, @startRow intSET @startRowIndex = (@startRowIndex - 1) * @maximumRowsIF @startRowIndex = 0SET @startRowIndex = 1SET ROWCOUNT @startRowIndexSELECT @first_id = StoriesID FROM Storie ORDER BY StoriesIdPRINT @first_idSET ROWCOUNT @maximumRowsSELECT Stories.StoryId, Chapters.ChapterName, Chapters.EnglishName, Translations.Translation,Stories.Verse, Stories.StoryFROM Chapters, Stories, TranslationsWHERE Chapters.ChapterId=Stories.ChapterId AND Translations.TranslationId = Stories.TranslationId  AND Stories.StoryId >= @first_idORDER BY Stories.StoryIdSET ROWCOUNT 0SELECT @totalRows = COUNT(StoryId) FROM Stories

View 3 Replies View Related

Need Help Adding Multiple Values To Dropdownlists Datatextfield

Jan 15, 2004

I'm trying to put a range of dates into the datatextfield of my ddl. I'm using the query:

string strProps2 = "SELECT sc_id, cast(begin_date AS varchar) + ' - ' + cast(end_date AS varchar) AS XYZ From Archived_Property_Changes WHERE Property_number = " + qryPN + " ORDER BY end_date";

but it gives me an empty ddl. the datavaluefield shows the correct results, but it's not displaying the correct data from the datatextfield. I removed the casts from the SQL query and it returns:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value

Below is my ddl code:

SqlCommand objCommandProps2 = new SqlCommand(strProps2, myConnection);
SqlDataReader objReaderProps2 = objCommandProps2.ExecuteReader();

ddlArchive.DataSource = objReaderProps2;
ddlArchive.DataValueField = "sc_id";
ddlArchive.DataTextField = "XYZ";
ddlArchive.DataBind();
ddlArchive.Items.Insert(0, "Select A Period");

Any thoughts are duely appreciated...

View 2 Replies View Related

DropDownLists Edit In Grid View To Display Names But Have Value Of User_ID ... Possible?

Mar 16, 2008

Hello,I have inserted a drop down list in my Edit template of Grid view.  This DDL should control the User_ID who is responsible for the Computer being edited.  However I want it to display the User Names rather than the user IDs.  I have a COMPUTERS and a USERS table.  They are related by having User_ID in both.  Below is my grid view with the parts i feel relative highlighted in bold:<asp:GridView ID="GridView1" runat="server" AllowSorting="True"         AutoGenerateColumns="False" DataKeyNames="Computer_ID"         DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"            GridLines="None">           <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />           <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />        <Columns>            <asp:CommandField ShowEditButton="True"/>            <asp:BoundField DataField="Computer_ID" HeaderText="Computer_ID"                 InsertVisible="False" SortExpression="Computer_ID" ReadOnly="true" />            <asp:BoundField DataField="Computer_Name" HeaderText="Computer Name"                 SortExpression="Computer_Name"/>            <asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer"                 SortExpression="Manufacturer"/>            <asp:TemplateField HeaderText="User Name" SortExpression="Name">                <EditItemTemplate>                    <asp:DropDownList ID="DDL_Name" runat="server" DataSourceID="SQLDataSource2" DataValueField="User_ID" SelectedValue='<%# Bind("User_ID") %>'></asp:DropDownList>                </EditItemTemplate>                <ItemTemplate>                    <asp:Label ID="lblName1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>                </ItemTemplate>            </asp:TemplateField>        </Columns>              <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />           <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />           <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />           <EditRowStyle BackColor="#999999" />           <AlternatingRowStyle BackColor="White" ForeColor="#284775" />    </asp:GridView>    <asp:SqlDataSource ID="SqlDataSource2" runat="server"        ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:AjaxControlToolkitWebSite1App_DataAssetDatabase.mdf;Integrated Security=True;User Instance=True"         ProviderName="<%$ ConnectionStrings:AssetDatabaseConnectionString.ProviderName%>"         SelectCommand="SELECT * FROM USERS" >    </asp:SqlDataSource>    <asp:SqlDataSource ID="SqlDataSource1" runat="server"        ConnectionString="Data Source=.SQLEXPRESS;AttachDbFilename=C:AjaxControlToolkitWebSite1App_DataAssetDatabase.mdf;Integrated Security=True;User Instance=True"         ProviderName="<%$ ConnectionStrings:AssetDatabaseConnectionString.ProviderName%>"         SelectCommand="SELECT COMPUTERS.Computer_ID, USERS.User_ID, COMPUTERS.Computer_Name, COMPUTERS.Manufacturer, USERS.Name FROM COMPUTERS INNER JOIN USERS ON COMPUTERS.User_ID = USERS.User_ID"         UpdateCommandType="StoredProcedure" UpdateCommand="StoredProcedure1"          >        <UpdateParameters>            <asp:Parameter Name="Computer_ID" Type="Int32" />             <asp:Parameter Name="User_ID" Type="Int32"/>             <asp:Parameter Name="Name" Type="String" />             <asp:Parameter Name="Computer_Name" Type="String" />            <asp:Parameter Name="Manufacturer" Type="String" />        </UpdateParameters>    </asp:SqlDataSource>    <br />    <br />    </form></body></html>  THANKS =] 

View 6 Replies View Related

SELECT A Single Row With One SqlDataSource, Then INSERT One Of The Fields Into Another SqlDataSource

Jul 23, 2007

What is the C# code I use to do this?
I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.

View 7 Replies View Related

Individual SqlDataSource() Or Common SqlDataSource() ?

Mar 8, 2007

i am using visual web developer 2005 with SQL Express 2005 with VB as the code behindi have one database and three tables in itfor manipulating each table i am using separate SqlDataSource() is it sufficient to use one SqlDataSource() for manipulating all the three tables ? i am manipulating all the tables in the same page only please help me

View 1 Replies View Related

Asp:sqldatasource - Sum And Contains

Aug 20, 2006

I have an asp:sqldatasource which is bound to a gridviewIn addition to this I would like it to a) see if there is a specif row/ item in it (ie item_id = 10 for any of the rows it has received) as I conditionally want to show another item outside of the gridview subject to if it is in the gridview or notb) show the sum of all the values within a certain column of returned rowsMany thanks

View 1 Replies View Related

SqlDataSource

Oct 11, 2006

How do I get the result of this select into a variableDim sqldsFindUserId As SqlDataSource = New SqlDataSource        sqldsFindUserId.ConnectionString = ConfigurationManager.ConnectionStrings("bluConnectionString2").ToString        sqldsFindUserId.SelectCommandType = SqlDataSourceCommandType.Text        Dim myUserIdCmd As String = "select pkUser from tblUsers where strDisplayName='" + myDisplayname + ""        sqldsFindUserId.SelectCommand = myUserIdCmd  '  The result  of this select statement is to be stored in a variable, how do I do it?

View 2 Replies View Related

SqlDatasource

Dec 18, 2006

Hi all

View 2 Replies View Related

Sqldatasource

Jan 15, 2007

hi all,
in all my 2.0 learnings and books i keep coming across the page element <asp:sqldatasource>.
I have always (in 1.1) used server side connections and adapters to bind my Sql datasets to any control needed.  Now that im learning 2.0 im finding it difficult to understand using control on the page to bind my data.  Can someone explain the benefits of using this data source?  Ideally i would like to keep my data access layer separate from my presentation layer but i'd really like to understand why this method seems so popular.
thanks in advance,
mcm

View 2 Replies View Related

Using SQLDataSource

Feb 23, 2007

Hi, I am new to ASP.NET 2.0 and I am trying to use VWB to bind my web site to a SQL Express edition. I used SQLDataSource to specify the .mdf file so I can connect to my tables but when I click on the advanced button to generate the Insert, Update, Delete SQL I find it grayed out and it cannot be clicked. I looked into several tutorials online and I couldn't find the problem, can anyone explain what I am missing or doing wrong? Any suggestion is very appreciated. Thanks 

View 2 Replies View Related

SQLDataSource

Mar 30, 2007

SELECT * FROM [CONTACTS] WHERE @ddl_value LIKE '%@txt_value%'
 
Why doesn't this not working
I am using SQLdatasource control to bind a gridview
If my query is wrong then what might be the correct one to work with like operator in the sqldatasource
Can any ony help me!

View 4 Replies View Related

SqlDataSource

Apr 12, 2007

Hello All,
 I have quick question ..
In my aspx page i have gridview  and Sql DataSource  object as you can see
<asp:sqldatasource id="SqlDataSource1" runat="server" ></asp:sqldatasource>
 
<asp:gridview id="GridView1" runat="server" allowpaging="True" allowsorting="True" autogeneratecolumns="False" datasourceid="SqlDataSource1">
<columns>
<asp:boundfield datafield="breakdownid" headertext="breakdownid" insertvisible="False"
readonly="True" sortexpression="breakdownid" />
<asp:boundfield datafield="ticketno" headertext="ticketno" sortexpression="ticketno" />
<asp:boundfield datafield="systemtype" headertext="systemtype" sortexpression="systemtype" />
<asp:boundfield datafield="break_date" headertext="break_date" readonly="True" sortexpression="break_date" />
<asp:boundfield datafield="subject" headertext="subject" sortexpression="subject" />
<asp:boundfield datafield="status" headertext="status" sortexpression="status" />
<asp:boundfield datafield="prioritylevel" headertext="prioritylevel" sortexpression="prioritylevel" />
<asp:boundfield datafield="mobiletype" headertext="mobiletype" sortexpression="mobiletype" />
</columns>
</asp:gridview>
In codebehind file  i call a function to get data from database. what i want is to bind the result to the sqlDataSourse not the gridview.
 I need to have the SqlDataSourse thier..  Any help please
 
 
Sub Page_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim objReader As New Dynamic.Reportsdemo
SqlDataSource1 = .objReader.Get_Tickets(1, 0, "all")
 
SqlDataSource1.DataBind()
objReader.objconnection.Close()
 
End If
End Sub
Thanks.
 
 

View 1 Replies View Related

How To Get A Value From SQLDataSource

May 28, 2007

Hi!Please tell me, how to get a simple value using SQLDataSource, I mean a number, or char, or string - any value, NOT DataTable 

View 3 Replies View Related

EOF With SqlDataSource

Jul 23, 2007

I am trying to get record from a table and verify it with a textbox i have a sqldatasource.
 i have a text box called txtEmail and this is my Select command. how can i get this working if its possible ?
something like txtEmail.text = SqlDataSource1.Secect then ... my code. (i dont know if this a correct way to do this)
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacstestConnectionString %>"
SelectCommand="SELECT FROM [t_CustomerAcct]"
 
thanks,

View 1 Replies View Related

Something About Sqldatasource

Aug 13, 2007

hi all,i am using sqldatasource for gridviewso that i can edit and update any row at the same place ..... and not to write any code for that....now later on if i wanna change the selectcommand of that sqldatasource how can i ? so that the edit and update will be same as it was.... 

View 2 Replies View Related

Using An SQLDataSource For Than Once

Aug 21, 2007

Hi,
I'm trying to go through a checkbox list and inserting them into a database using a sqldatasource with the following code:For Each li As ListItem In Locations_Checkbox.Items
If li.Selected = True Then
 
Dim DataSource2 As SqlDataSource = CType(InsertProgrammeLocations, SqlDataSource) DataSource2.InsertParameters.Add("ProgrammeID", li.Value)
DataSource2.Insert()
 
 
End If
Next
When more than one checkbox is ticked, I'm getting the error 'The variable name '@ProgrammeID' has already been declared'. How do I close or reset my Datasource before I try and use it again?
Thanks for your help
  
 

View 3 Replies View Related

Sqldatasource

Oct 28, 2007

please explain selectparameter collection and conflict detection property and filterparameter
mohsen

View 1 Replies View Related

What Is SqlDataSource

Oct 29, 2007

Hi, I want to know when to use an sqlDataSource object because I used to populate for example a listBox control in visual studio net 2003 from AQLK server database by using a connection object, command object, dataAdapter object and a DataSet object. I discovered if I use sqlDataSource object (using visual studio net 2005) ,all I need is to write the connection string and a Select statement as properties for that sqlDataSource, so why to use the above mentioned objects(connection,command,adapter,dataset) while I can access any database in sql server through the use of sqlDataSource?
I appreciate if you can explain to me the difference and when to use an sqlDataSource
thx

View 1 Replies View Related

SqlDataSource

Dec 4, 2007

How can I update more than one table with one UpdateString in SqlDataSource?

View 5 Replies View Related

Do You Really Use SqlDataSource?

Dec 9, 2007

Hi,
I have an application w/ n-tier design so I've never used the SqlDataSource up to this point but having to do my own sorting for GridViews is not something I want to keep dealing with. I'd like to take advantage of some of the packaged features too.
My question is: are there any purists out there who opted to use SqlDataSource. If so, what do you think about it? It's nice that SqlDataSource makes things simple but having data classes and dealing w/ exceptions in those classes certainly make an application pretty robust. Should I entertain the idea of using SqlDataSource or stay as a purist and keep doing things the old fashioned way?

View 1 Replies View Related

Sqldatasource?

Dec 30, 2007

How to display returned data from sqldatasurce in a textbox.
This code is not working TextBox1.Text = SqlDataSource2.ToString(); Thanks Lot.

View 2 Replies View Related

SqlDataSource

Jan 16, 2008

Hey all,I've just started to use asp.net and so far have found it fairly easy. The only problem I've come across is with putting variable clauses into the SqlDataSources.This is one example of what I've done trying to get this to work. <asp:SqlDataSource ID="ClaimsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT TOP 20 dbo_ClaimStatus.ClaimStatus, dbo_CLAIMS.PACKET, dbo_INSURED.NAME, dbo_FEES.INSURER, dbo_FEES.CLAIM_NUMBER, dbo_CLAIMS.LOSS_DATE, dbo_CLAIMS.RECEIVED, dbo_CLAIMS.LOSS_LOCATION, dbo_CLAIM_TYPES.CODE FROM ( ( ( ( dbo_CLAIMS INNER JOIN dbo_CLAIM_TYPES ON dbo_CLAIMS.CLAIM_TYPE = dbo_CLAIM_TYPES.CODE ) INNER JOIN dbo_ClaimStatus ON dbo_CLAIMS.StatusID = dbo_ClaimStatus.ClaimStatusID ) INNER JOIN dbo_FEES ON dbo_CLAIMS.PACKET = dbo_FEES.PACKET ) INNER JOIN dbo_INSURED ON dbo_CLAIMS.PACKET = dbo_INSURED.PACKET ) WHERE dbo_ClaimStatus.ClaimStatus = @claimStatus"> <FilterParameters> <asp:QueryStringParameter Name="claimStatus" QueryStringField="ctl00$MainContent$claimStatus" /> </FilterParameters></asp:SqlDataSource>I'm posting claimStatus from a previous page using PostBackUrl on an <asp:Button /> tag and claimStatus is an <asp:DropDownList /> tag.Any idea's as to why this doesn't work?Nalum 

View 2 Replies View Related

SqlDataSource

Feb 24, 2008

Dear Friends in my project , i' ve used two SqlDataSource, one button and one gridview control;
the process that i want to do is when i click the button control ,according the  if structure in this button control ; one of the SqlDataSource control assign to the gridview control DataSource property (but i assign the DataSourceID property for the gridview , it runs);
but i couldnt do it, what can i do for it? (my code  doesnt give any errors but doesnt do anything too)
my code is here;
protected void btnSearch_Click(object sender, EventArgs e)     {         if (txtSearch.Text != null){             SqlDataSource3.SelectParameter["key"].DefaultValue = txtsearch.Text;             Gridview1.DataSource = SqlDataSource3;             GridView1.DataBind();         }         else         {             SqlDataSource1.SelectParameters["keySession"].DefaultValue = cbSession.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyClass"].DefaultValue = cbClass.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyUnit"].DefaultValue = cbUnit.SelectedItem.ToString();             Gridview2.DataSource = SqlDataSource1;             GridView2.DataBind();         }
 

View 1 Replies View Related

SqlDataSource

Feb 24, 2008

Dear Friends in my project , i' ve used two SqlDataSource, one button and one gridview control;
the process that i want to do is when i click the button control ,according the  if structure in this button control ; one of the SqlDataSource control assign to the gridview control DataSource property (but i assign the DataSourceID property for the gridview , it runs);
but i couldnt do it, what can i do for it? (my code  doesnt give any errors but doesnt do anything too)
my code is here;
protected void btnSearch_Click(object sender, EventArgs e)     {         if (txtSearch.Text != null){             SqlDataSource3.SelectParameter["key"].DefaultValue = txtsearch.Text;             Gridview1.DataSource = SqlDataSource3;             GridView1.DataBind();         }         else         {             SqlDataSource1.SelectParameters["keySession"].DefaultValue = cbSession.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyClass"].DefaultValue = cbClass.SelectedItem.ToString();             SqlDataSource1.SelectParameters["keyUnit"].DefaultValue = cbUnit.SelectedItem.ToString();             Gridview1.DataSource = SqlDataSource1;             GridView1.DataBind();         } }

View 1 Replies View Related

SQLDataSource && ADO.Net

Apr 16, 2008

Could someone help me with syntax?  Everything works until line 23.  At that point, I get a NullReferenceException.  When I examine the SqlDataSource object, everything inside reads "Object cannot be null" or "The pointer for this method was null."  The SQLDataSource looks ok, just before executing line 23.
Does anyone have a complete example of how to do this ADO operation?
Thank you. 1 Dim fv As FormView = Nothing
2 Dim sds As New SqlDataSource
3
4 ' ===== Lookup connection string =====
5 sds.ConnectionString = ConfigurationManager.ConnectionStrings("LocalSQLServer").ToString
6
7 ' ===== Define command statements =====
8 cmdSelect = _
9 "SELECT rowid, FRScrnLev, FRPgmLev, " + _
10 "FRFName, FRLName, FRIDate, OverRide, OverRideDesc " + _
11 "FROM PSB_Pre WHERE PSBid = @PSBid"
12
13 ' ===== Get handle to Formview =====
14 fv = CType(MultiView1.Views(0).FindControl(ViewState(VS_VIEW).ToString), FormView)
15
16 ' ===== Complete definition of data source =====
17 sds.SelectCommand = cmdSelect
18 sds.SelectCommandType = SqlDataSourceCommandType.Text
19
20 sds.UpdateCommand = cmdUpdate
21 sds.UpdateCommandType = SqlDataSourceCommandType.Text
22
23 sds.SelectParameters("PSBid").DefaultValue = CP.PsbId
24
25 ' ===== Bind data source to FormView. =====
26 fv.DataSource = sds
27 fv.DataBind()

View 2 Replies View Related

Get A Value From Sqldatasource

May 26, 2008

I have an sqldatasource that has a select statement and i just wanna pull a value out of it
a single value
row 0 colum 0
and assign it to a string
the coloum is an interger in the database

View 1 Replies View Related

Sqldatasource Help

Jun 4, 2008

Hi, i am trying to use a sqldatasource to update a table and when i go and update the table it puts a null value in for all of my fields. I am not sure what is happening and i have never used on of these before. Is there some code that i need to write to accompany the sqldatasource or am i just missing something. I have posted the code below. Thanks.<asp:GridView ID="grdSize" runat="server" AutoGenerateColumns="False"
DataSourceID="sqlbk" Width="295px" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<RowStyle CssClass="grdsizerow" BackColor="#EEEEEE" ForeColor="Black" />
<EditRowStyle CssClass="grdsizeedit" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
<asp:TemplateField HeaderText="Diameter" SortExpression="Diameter">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" Width="60px" Height="16px" runat="server" Text='<%# Eval("Diameter") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Diameter") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="HighLimit" SortExpression="HighLimit">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" Width="60px" Height="16px" runat="server" Text='<%# Eval("HighLimit") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("HighLimit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LowLimit" SortExpression="LowLimit">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" Width="60px" Height="16px" runat="server" Text='<%# Eval("LowLimit") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("LowLimit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle CssClass="grdsizeheader" BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#DCDCDC" />
</asp:GridView><asp:SqlDataSource ID="sqlbk" runat="server"
ConnectionString="<%$ ConnectionStrings:qdbConnectionString %>" SelectCommand="Select ID, screwdia as Diameter , HighLimit, LowLimit from ScrewSize"
 
UpdateCommand="UPDATE ScrewSize SET screwdia = @dia, HighLimit = @high, LowLimit = @low WHERE (ID = @ID)">
<UpdateParameters>
<asp:Parameter Name="dia" Type="String" />
<asp:Parameter Name="high" Type="String" />
<asp:Parameter Name="low" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

View 4 Replies View Related

SQLdatasource

Nov 22, 2005

Hi
When i am configuring the SQLdatasource control the checkbox of  Generate insert,updata and delete is disabled i wnat to check this checkbox
can anybody tell me how i enable this checkbox
 
thanks

View 1 Replies View Related

SQLDATASOURCE VS. ADO.NET

Nov 27, 2005

Hello,What's the difference between using sqldatasource to get data vis-a-vis ado.net?Both can retrieve datareaders and datasets.Any thoughts? Which one is better?From my experience, code-wise, sqldatasource is muuuuch easier.a s a f.  . .

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved