How To Populate Grid From SQLDataSource When Clicking On Button
Nov 20, 2007how to populate grid from SQLDataSource when clicking on button
View 2 Replieshow to populate grid from SQLDataSource when clicking on button
View 2 RepliesI want to validate my input report parameters while user clicks the View Report Button. How can I accompalish this in SSRS.
ex: Report parameters should accept only numberic values.
I'm trying to restore a database using SSMS GUI. In "Select backup devices" window if I click the Add button there the window and the whole process hangs like it will never work.
I tried to clear backup history, but that didn't solve it.
I tried with a couple of other databases, but same thing. It was working fine!
I have below SP that populates immunization into a grid. I need to add last_name, first_name from person table.
Each record in dB is tied to a patient by their person_id and Person table has this as well.
All I need to tie this grid and add last_name, first_name into this grid. I added 2 lines but its not working for me?
quote:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ngkbm_unmapped_vaccines]
[Code] ....
Hi
I'd like to be a little more efficient in my approach when using databases. Although my site is very simple with a low hit rate expected, I would still like to learn the best methods in designing server load conscious code.
Basically, I have a page where I'd like to show events broken down into days of the week (Monday - Sunday). All the events contain the same data and only difference being the day. Right now, the only way I know how to make this work is to create a unique sqlDataSource (select * where Day = Monday) then assign it to a ‘Monday’ grid view. I then repeat this same process for each day of the week.
As the data is always the same, is there a way to make only call to the database returning all the data, then close the connection and then separate the data there after. To me this seems to be a much more efficient way to manage the data???
Thanks for any help/supportRichard
I am sending a GUID to a form via the query string. If it exists I use helper functions to load most of the form text boxes. However, if it does not then a blank form is presented and the GUID is stored in a hidden field.
Regardless, I use this hidden field to populate a grid that is attached to a sqldatasource.
If I then add new datarows to the backend database programmatically, I cannot 'requery' the datasource to include those row upon a postback. I cannot seem to find a simple way to force the sqldatasource to rerun the query.
Can anyone help.
hi .. i have a SqlDataSource, GridView & a Button .. i want to increase the condition in the "SelectCommand" below by one everytime i click the button .. i mean to be like that ID < 8 instead of ID < 7
so, the GridView will show 7 ID's instead of 6 .. and it will increase everytime i hit the button<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:connectionstring %>"
SelectCommand="SELECT * FROM [table1] WHERE ID < 7">
</asp:SqlDataSource>
Ok, this seems really straightforward, but I'm completely lost. I created a sqldatasource control that uses an INSERT stored procedure. I can click on test it tests just fine, inserts everything into the database.Now, I want this sqldatasource control to fire when a button is clicked, but I have no idea how to do this, I looked at the parameters and cant find an execute or anything like that to use. Let me know how to execute this sqldatasource, it'd really help me out. I know you can do EVERYTHING in the code behind file, but I'm rather new to VB and I'm probably gonna save that for another day. Here's what I have now:basic sqldatasource : <asp:SqlDataSource ID="SqlProcDS" runat="server" ConnectionString="<%$ ConnectionStrings:pubsConnectionString %>" InsertCommand="ins_test" InsertCommandType="StoredProcedure" SelectCommand="ins_test" SelectCommandType="StoredProcedure"> <SelectParameters> <asp:ControlParameter ControlID="TextBox1" Name="a" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBox2" Name="b" PropertyName="Text" Type="String" /> <asp:ControlParameter ControlID="TextBox3" Name="c" PropertyName="Text" Type="String" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="a" Type="String" /> <asp:Parameter Name="b" Type="String" /> <asp:Parameter Name="c" Type="String" /> </InsertParameters> </asp:SqlDataSource>in the vb file : Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 'Somehow execute sqlProcDS here?!End Sub
View 1 Replies View Relatedi am using 2 textbox to search name and instituition of some students. on button click need to display the result on gridview. but i dont get any result.. pl adviceSqlDataSource1.SelectCommand = "SELECT Sname, Address, Instituition, Role, Testgroup, Email FROM std_det WHERE (Sname LIKE '%'+@Param1+'%') AND (Instituition = 'RASET') AND (Role LIKE '%'+@Param2+'%') AND (Instituition = 'RASET')"; name.ControlID = "TextBox3"; name.DefaultValue = "%"; name.Name = "Param1"; name.PropertyName = "Text"; inst.ControlID = "TextBox4"; inst.DefaultValue = "%"; inst.Name = "Param2"; inst.PropertyName = "Text"; //SqlDataSource1.Select(DataSourceSelectArguments.Empty); SqlDataSource1.SelectParameters.Add(name); SqlDataSource1.SelectParameters.Add(inst); SqlDataSource1.DataBind(); //DataView dv = (DataView)this.SqlDataSource1.Select(DataSourceSelectArguments.Empty); GridView2.DataSourceID = "SqlDataSource1"; GridView2.DataBind();
View 2 Replies View Relatedi have formview and gridview in onepage, and formview bind to one sqldatasource, which have select commandtype is storedprocedure,
now stored procedure have one optional parameter and select command.
in gridview i have one button,now i want when user click on tha button that record's value comes in formview and its mode is edit.
now for that i have to pass that stored procedures parameter value,to stored procedure now how can i add the parameter value when the onclick event of gridview button is fire.
thanks
How does one programmatically retrieve the results from a sqldatasource that has had a filterexpression applied to it?
Let me elaborate, here is my code:
SqlDataSource1.FilterExpression = "MenuType = 'myfilteredvalue'"
Dim _dv As DataView = CType(SqlDataSource1.Select(DataSourceSelectArguments.Empty), System.Data.DataView)
_dv.Table.TableName = "Menu" Dim ds As New DataSet("Menus") ds.Tables.Add(_dv.Table.Copy()) 'Add relation: ParentID under MenuID
Dim relation As New DataRelation("ParentChild", ds.Tables!Menu.Columns!MenuID, ds.Tables!Menu.Columns!ParentID, True) relation.Nested = True
ds.Relations.Add(relation)
What I'm doing is, I have a sqlDataSource that pulls all the data from my DB. With this data in the sqlDataSourceSource, I want to then populate an XMLDatasource (via a dataset) with only the records I need, i.e. the filter. However, after I apply my filter above, the sqlDataSoruce still contains all the records. I thought maybe if I did a sqlDataSource.Bind() after my SqlDataSource.FilterExpression, but that didn't do anything either.In laymans terms:I want to say something like: dataset = sqldatasource.filter(my filter expression).
I am using a SqlDataSource in my form page to query the DB and populate a GridView. If for example the value of Cell (3) is "1" I want to display the values of two other fields, Cells (6) & (7) in two ASP BoundFields 4 and 5.
Then, When Cell(3) = "2" I want to compare two Cells (8) & (9) procede as above, placing those values in ASP BoundFields 4 and 5.
Ive tried using the code below to do the comparisons of all the fields that I am using and then not displaying them with "Visible=False" as I dont want all the fields to be visible... But this method has become quite cumbersome to manage.
Is there a better way to do this??
Thanks!
Protected Sub TestStatus_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.Cells(3).Text = 1 Then
e.Row.Cells(4).Text = "<font color=Green><b>" & e.Row.Cells(6).Text & "</b></font>" e.Row.Cells(5).Text = "<font color=Red><b>" & e.Row.Cells(7).Text & "</b></font>"
e.Row.Cells(6).Visible = False e.Row.Cells(7).Visible = False e.Row.Cells(8).Visible = False e.Row.Cells(9).Visible = False
End If
If e.Row.Cells(3).Text = 2 Then
e.Row.Cells(4).Text = "<font color=Orange><b>" & e.Row.Cells(8).Text & "</b></font>" e.Row.Cells(5).Text = "<font color=Blue><b>" & e.Row.Cells(9).Text & "</b></font>"
e.Row.Cells(6).Visible = False e.Row.Cells(7).Visible = False e.Row.Cells(8).Visible = False e.Row.Cells(9).Visible = False
End If End If End Sub
<!-- Trying
to create a GridView Survey form:
Hi [User]
Do you have these assets?
[Gridview]
Tag Number Response
123
[Yes ] [No] [Comments textbox]
234
[Yes ] [No] [Comments textbox]
Goal: The desire
is for the user to click Yes or No and have the database updated with the
user's name, date, response and any comments.
So far, I have
created SqlDataSource with Select and Update commands, created the gridview and
response buttons, setup the RowCommand and On_Updating Functions.
Problems:1) If I call the update() function for SqlDataSource1 and misuse the Defaultvalue parameters to run the sql, no update is posted to the database.
2) If I use the On_Update function to set the parameter values, I get "Data type mismatch in criteria expression." (Additionally, the On_Update function runs twice which I don't understand)Can anyone tell
me what/why? (and how to fix it?)Sorry for the deluge, but here is the code:
-->
<%@ Page
Language="VB"
%>
<html>
<head id="Head1" runat="server">
<title>Asset Survey</title>
</head>
<SCRIPT runat="server">
Protected Sub SqlDataSource1_Selecting(ByVal
sender As Object,
ByVal e As
System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
e.Command.Parameters("Name1").Value = User.Identity.Name
End Sub
Protected Sub SqlDataSource1_Updating(ByVal
sender As Object,
ByVal e As
System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating 'For some
reason, this function executes twice '2nd execution gets error: "Data type
mismatch in criteria expression." 'e.Command.Parameters("PrimaryKey1").Value
= intPrimaryKey 'e.Command.Parameters("Responder1").Value
= strUser 'e.Command.Parameters("ResponseDate1").Value
= dtModDate 'e.Command.Parameters("Response1").Value
= strResponse 'e.Command.Parameters("ResponseComments1").Value
= strComments End Sub
Protected Sub
GridView1_RowCommand(ByVal sender As Object, ByVal e As
GridViewCommandEventArgs) _
Handles
GridView1.RowCommand
Dim
GridRow1 As Integer
= Convert.ToInt32(e.CommandArgument)
If
e.CommandName = "UpdateYes" Then
'code here to disable buttons and textbox
'...
SqlDataSource1.UpdateParameters("Response1").DefaultValue
= "Yes"
End If
If
e.CommandName = "UpdateNo" Then
'code here to disable buttons and textbox
'...
SqlDataSource1.UpdateParameters("Response1").DefaultValue
= "No"
End If
'if I use the SqlDataSource1_Updating
function, I get the mismatch error
'but if I (mis)use the DefaultValue
parameter, no update occurs.
SqlDataSource1.UpdateParameters("ResponseComments1").DefaultValue = _
GridView1.Rows(GridRow1).FindControl("txtComments").ToString
SqlDataSource1.UpdateParameters("Responder1").DefaultValue =
User.Identity.Name
SqlDataSource1.UpdateParameters("ResponseDate1").DefaultValue =
DateTime.Now
SqlDataSource1.UpdateParameters("PrimaryKey1").DefaultValue = _
GridView1.Rows(GridRow1).Cells(0).Text
Try
SqlDataSource1.Update() 'Error Here if I use on_updating: "Data
type mismatch in criteria expression."
Catch except As Exception
' Handle the Exception.
End Try
End Sub
</SCRIPT>
<body>
<form id="formInv"
runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$
ConnectionStrings:LocalTestMDB %>"
ProviderName="<%$
ConnectionStrings:LocalTestMDB.ProviderName %>"
SelectCommand="SELECT
[PrimaryKey], [Name], [AssetTag], [Response], [Responder],
[ResponseDate],[ResponseComments] FROM [Tablename] WHERE ([Name] = ?) ORDER BY
[Login Name], [AssetTag]"
UpdateCommand="Update
[Tablename] SET [Response]=@Response1, [Responder]=@Responder1,
[ResponseDate]=ResponseDate1, [ResponseComments]=ResponseComments1 WHERE
[PrimaryKey]=@PrimaryKey1"
OnSelecting="SqlDataSource1_Selecting"
OnUpdating="SqlDataSource1_Updating">
<SelectParameters>
<asp:Parameter DefaultValue="" Name="Name1" Type=String />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ResponseComments1"
Type=String DefaultValue=""
/>
<asp:Parameter Name="Response1"
Type=String DefaultValue=""
/>
<asp:Parameter Name="ResponseDate1"
Type=DateTime DefaultValue="#8/1/2007
12:00:00PM#" />
<asp:Parameter Name="Responder1"
Type=String DefaultValue=""
/>
<asp:Parameter Name="PrimaryKey1"
Type=Int32 DefaultValue=0 />
</UpdateParameters>
</asp:SqlDataSource>
<span>Hi, Please
respond by clicking "Yes" or "No" for each asset</span>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataKeyNames="PrimaryKey"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="PrimaryKey"
HeaderText="PrimaryKey"
AccessibleHeaderText="PrimaryKey" Visible=False/>
<asp:BoundField DataField="Name"
HeaderText="Name"
SortExpression="Name"
AccessibleHeaderText="Name" />
<asp:BoundField DataField="AssetTag"
HeaderText="AssetTag"
SortExpression="AssetTag"
AccessibleHeaderText="AssetTag"
/>
<asp:TemplateField
HeaderText="Please
Respond">
<ItemTemplate>
<asp:Button ID="btnYes" runat="server"
Text="Yes"
Visible="true"
CommandName='UpdateYes'
CommandArgument='<%#
CType(Container, GridViewRow).RowIndex %>' />
<asp:Button ID="btnNo" runat="server"
Text="No"
Visible="true"
CommandName='UpdateNo'
CommandArgument='<%#
CType(Container, GridViewRow).RowIndex %>' />
<br />
<asp:Label ID="lblComments"
runat="server"
Text="Comments:"
Visible=True></asp:Label>
<asp:TextBox ID="txtComments"
runat="server"
Text='<%#
Bind("ResponseComments") %>'
Visible=True MaxLength=512 Height=24 Width=320 Wrap=True Enabled=True
TextMode=MultiLine></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
Beginner question, I know -- but in ASP.NET 2.0, I can't figure out (or find out) how to populate a TextBox with data from the db using a SqlDataSource control (without using a formview control)???
Any help would be greatly appreciated!!
I want to update two tables in one page. So I created two FormView bound on two SqlDataSource controls, and I create a Update button on the bottom of page. And I writen some codes as below:
btnUpate_Click(object sender, EventArgs e){
sqlDataSource1.Update();
sqlDateSource2.Update();}
But, the records haven't updated.
In SqlDataSource2_Updating() function, I found all the parameters is null.
So, how to modify my code to do it.
Zhang
When I click on an error message in the messages/results screen, it no longer highlights the correct section of code to show where the error is - somehow it has gone out of sync and just highlights a random piece of code.
Does anyone know how to reset it so that the error in the messages screen matches up to the correct line of code?
Thanks
My boss wants to know why I can sort information in the Enterprise Manager by clicking the column headings but he can't; like in the Job window clicking status to sort the jobs by status so all of the 'executing' jobs are listed first. I said no problem, let's apply SP2 and that should do the trick. To my chagrin it did not solve the problem. I would appreciate any ideas.
Thanks!
I've got a package that was imported from SQL 2000 into SQL 2005. I'm trying to edit it in Business Int. Dev Studio. When I open what used to be a data pump step in 2000, I'm able to edit items. However, when I click OK, it puts an error right below the buttons:
"" is not a value type
And it won't let me save my changes. I have no idea where this error is coming from. All the data pumps in this package cause the same error. Your help is appreciated.
In SQL Server 2008 when I click the middle button I could scroll up and down(scroll wheel) by just flicking the mouse. We just upgraded to 2012 and I can't do that on my Lenovo ThinkPad. I am using an external wired usb mouse(Intelli Mouse) to scroll.
I have SQL server 2008 and 2012 installed on the same machine scrolling works in 2008 but not in 2012.
Hi,
We have few reports which users want to export rather than see them on the web. Is there any way to directly export the report (in a specified format say .CSV) when user clicks on generate report. This way they don't have to wait till report is rendered on the web page and then export it.
Can anyone help?
When I select the database and right click. I receive the following error:
Cannot show requested dialog
Additional Information:
Cannot show requested dialog (sqlMgmt)
Property Owner is not available for Database '[DB_name]'. This property may not exist for this object,
or may not be retrievabledue to insufficient access rights. (Microsoft.SqlServer.Smo)
I am using SQL server 2005.
We setup a new Shared SQL server 2014 Web and transferred all SQL databases over. However when customers connect via SQL Management Studio they now get VIEW STATE error when right clicking on any table on any database.
Check screenshot.
Follow-up to:
http://forums.asp.net/t/1237676.aspx
The update command seems to be deleting my data. If I set the Parameter "DefaultValue" to "NULL" then it updates that field to the literal string: NULL
WTH
Nick
<UpdateParameters>
<asp:Parameter Name="DevelopmentArea" Type="String"/>
<asp:Parameter Name="DevelopmentGoals" Type="String" />
<asp:Parameter Name="DevelopmentPlans" Type="String" />
<asp:Parameter Name="CurrentStatus" Type="String" />
<asp:Parameter Name="FutureState" Type="String" />
<asp:Parameter Name="DetermineFactor" Type="String"/>
<asp:Parameter Name="MentorRequested" Type="Boolean" DefaultValue="False"/>
<asp:Parameter Name="MentorList" Type="String"/>
<asp:Parameter Name="CheckPointDate" Type="DateTime" />
<asp:Parameter Name="DateUpdated" Type="DateTime" />
<asp:Parameter Name="PlanPKID" Type="Int32" />
</UpdateParameters>
Hi,
I just developed a ASP.NET website with SQL Server 2005 as database. I am having connection crash problem when multiple user click on same link to fetch data from the database. If users click on different links or there is few seconds of time gap between the data access, then it works fine. But the connections crash problem only occurs when 2 or more users click same link at same time.
I am using the following kind of Datalayers to access the data from database:
public static ContentInformation GetContentForUpdate(int ContentId)
{
ContentInformation result = new ContentInformation(); ;
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.Connection = Connection;
command.CommandText = "Content_GetContentForUpdate1";
SqlParameter parameter = new SqlParameter("@ContentId", SqlDbType.Int);
parameter.Direction = ParameterDirection.Input;
parameter.Value = ContentId;
command.Parameters.Add(parameter);
try
{
command.Connection.Open();
SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
if (reader.Read())
{
// read the data
}
reader.Close();
}
catch (SqlException ex)
{
Trace.TraceError(ex.Message);
throw ex;
}
finally
{
command.Connection.Close();
}
return result;
}
I would be really grateful if someone can help me out with this problem. Waiting for the soonest reply. Thanks.
Hi,
I just developed a ASP.NET website with SQL Server 2005 as database. I am having connection crash problem when multiple user click on same link to fetch data from the database. If users click on different links or there is few seconds of time gap between the data access, then it works fine. But the connections crash problem only occurs when 2 or more users click same link at same time.
I am using the following kind of Datalayers to access the data from database:
public static ContentInformation GetContentForUpdate(int ContentId)
{
ContentInformation result = new ContentInformation(); ;
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.Connection = Connection;
command.CommandText = "Content_GetContentForUpdate1";
SqlParameter parameter = new SqlParameter("@ContentId", SqlDbType.Int);
parameter.Direction = ParameterDirection.Input;
parameter.Value = ContentId;
command.Parameters.Add(parameter);
try
{
command.Connection.Open();
SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
if (reader.Read())
{
// read the data
}
reader.Close();
}
catch (SqlException ex)
{
Trace.TraceError(ex.Message);
throw ex;
}
finally
{
command.Connection.Close();
}
return result;
}
I would be really grateful if someone can help me out with this problem. Waiting for the soonest reply. Thanks.
what datafield shoud i put in my database if its a checkbox option? coz in my datagrid i added a checkedbox so that i can easily manipulate it.but when i run it. it produces error. and doesnt recognize the checkbox column.it said that there none in the datasource.but i dont know what should i put in the database! pls help!thanks
View 1 Replies View Relatedhi, i have done some testing and its only when i put a grid view or any other type of data viewer on the page, and then connect it to the sql datasource that i get an error
Line 1: Incorrect syntax near ')'.
now i really cant figure out what it is, here is the code i am using
SQL data source code :
asp:SqlDataSource ID="SQLDS_view_one_wish" runat="server" ConnectionString="<%$ ConnectionStrings:wishbank_DBCS %>"
SelectCommand="SELECT [msg], [Date_Time] FROM [tbl_MSG] WHERE (([Activated] = @Activated) AND ([msgID = @msgID]) )ORDER BY [Date_Time] DESC">
<SelectParameters>
<asp:Parameter DefaultValue="Y" Name="Activated" Type="String" />
<asp:SessionParameter Name="msgID" SessionField="sWV" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
session variable code which sends it to this page
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
Session["sWV"] = row.Cells[1].Text;
Response.Redirect("www/viewwf.aspx");
}
if you have an idea please let me know as im stuck!
hi,
now theres something i want to achieve but, again dont know how :-(
In a grid of my site it needs to be able to select an item, ( not with checkboxes) but maybe when you click on the item in the FromName column then
the data in the column in my database messageTEXT needs to be able to show in a textbox.( textbox is outside of grid)
now i was thinking that maybe it is need to be done with datareaders or something?
Greetz
Roy
Is it possible to have a design grid in SQL server like the one you have in Access when you create a query ?
View 10 Replies View RelatedHas anyone here heard or come across an article or write up about GridComputing in SQL Server 2000?Bharathihttp://www.vkinfotek.com
View 2 Replies View RelatedCan you turn on a grid in the designer to assist you with aligning tasks, etc. I've trie all kinds of things, but can't get a grid. Or even maybe rules? I'm probably missing something real simple, but can't find.
View 7 Replies View RelatedWhat 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.
Hi Guys..
i don't know weather is it possible or not..but Can any One tell's me How can i refresh the Chart Values.. acutally what's happening..
i have two Chart in a reprot .. One is Main Category and other one is SubCategory... acutally what i want.. in Main Category chart sum of Quantities of Subcategory values comes in bar or any other format.. and when i click on Main chart any bar it's refresh the other chart and return the result of subcategory under that main category in details...
i don't know is this possible .. acutally i m very new in reproting.. infact that's my first report.. so i want to do this.. if any article or any help anyone can provide me..
Thanks