sqldatasource

How to set SelectedValue of DropDownList in GridView EditTemplate

本秂侑毒 提交于 2019-11-30 20:03:43
I am trying to do this as asked earlier. The only difference that I found is additional List item that was included in above code. I tried to use AppendDataBoundItems=true but it is still not working. I also want to set the its default value to the value that was being displayed in label of itemtemplate i.e. DropDownList's SelectedValue='<%# Eval("DepartmentName") %>' but thie property is not available to me in dropdownlist. What could be the reason. ?? <EditItemTemplate> <asp:DropDownList ID="ddlDepartment_Edit" runat="server" DataSourceID="dsDepartment_Edit" DataTextField="DepartmentName"

How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?

两盒软妹~` 提交于 2019-11-30 18:34:25
For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source. I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes mess. So can I somehow define this parameter in .aspx file? <SelectParameters> <asp

How to use User.Identity.Name as a parameter for SqlDataSource in ASP.NET?

旧城冷巷雨未停 提交于 2019-11-30 16:51:34
问题 For SqlDataSource I can configure the external source for the incoming paramater. For example it might be a QueryString, Session, Profile and so on. However I do not have an option to use User as a source. I know that I could provide value for the parameter in Inserting,Selecting,Updating,Deleting events. But I do not think that this is an ellegant solution because I have some parameteres already definied in aspx file. I do not want to have parameters defined in two separate places. It makes

empty gridview although the sqldatasource has values

£可爱£侵袭症+ 提交于 2019-11-30 05:32:48
问题 I have really weird situation. I've created new aspx page, and without using ANY custom logic objects (everything created with visual studios wizards) tried to create grid view from sqldatasource. The data comes from stored procedure, with single parameter which has default value. when I refresh the schema or click "test query", I see result rows and GridViews fields are corectly created. But when I run the page there is no grid view (it's simply empty - when I add EmptyDataTemplate it is

asp.net dropdownlist - add blank line before db values

让人想犯罪 __ 提交于 2019-11-30 04:18:47
On my page I have a DropDownList which I populate with database values from an SqlDataSource (see code below). How can I add my own text or a blank line before the values? <asp:DropDownList ID="drpClient" runat="server" Width="200px" AutoPostBack="True" DataSourceID="dsClients" DataTextField="name" DataValueField="client_id"> </asp:DropDownList> <asp:SqlDataSource ID="dsClients" runat="server" ConnectionString="my_connection_string" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [client_id], [name] FROM [clients]"> </asp:SqlDataSource> Thanks. P.S. Do you recommend using a

How to set SelectedValue of DropDownList in GridView EditTemplate

左心房为你撑大大i 提交于 2019-11-30 04:16:01
问题 I am trying to do this as asked earlier. The only difference that I found is additional List item that was included in above code. I tried to use AppendDataBoundItems=true but it is still not working. I also want to set the its default value to the value that was being displayed in label of itemtemplate i.e. DropDownList's SelectedValue='<%# Eval("DepartmentName") %>' but thie property is not available to me in dropdownlist. What could be the reason. ?? <EditItemTemplate> <asp:DropDownList ID

Changing SqlDataSource.SelectCommand at runtime breaks pagination

余生颓废 提交于 2019-11-29 05:02:16
I have a GridView bound to a SqlDataSource with a default SelectCommand defined as such: <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet" ConnectionString="<%$ ConnectionStrings:MyConn %>" ProviderName="MySql.Data.MySqlClient" SelectCommand="select * from blah blah" /> There are cases where I have to change this query dynamically at runtime, so I do the following: SqlDataSource1.SelectCommand = sql; // 'sql' is the new query GridView1.PageIndex = 0; GridView1.EditIndex = -1; GridView1.SelectedIndex = -1; GridView1.DataBind(); updatePanel.Update(); This works just

SqlDataSource vs ObjectDataSource

放肆的年华 提交于 2019-11-28 06:56:26
If a web page needs some data, why not just have a SQLDataSource call a stored procedure? Why use an ObjectDataSource to call a business object that then calls the stored procedure? I understand that other apps (lets say desktop apps) built on the .net framework can access the business objects, but what if the application will always be only a web app? To be more clear: When should one use an SqlDataSource or ObjectDataSource ? How does one motivate the choice? marc_s Having just a SQLDataSource is perfectly valid, if it's just a demo, a prototype, or a quick hack. It's fast, it's easy, it

“Server” vs “Data Source” in connection string

一笑奈何 提交于 2019-11-27 20:20:31
I'm new to SqlServer, right now I have SqlLocalDb installed to work locally. Good, but I can see two connection strings typically and both works: Data Source=(localdb)\v11.0;Integrated Security=true; and Server=(localdb)\v11.0;Integrated Security=true; What exact difference is there between the two? Damien_The_Unbeliever For the full list of all of the connection string keywords, including those that are entirely synonymous, please refer to the SqlConnection.ConnectionString documentation : These are all entirely equivalent: Data Source Server Address Addr Network Address Exel Gamboa ... There

Changing SqlDataSource.SelectCommand at runtime breaks pagination

末鹿安然 提交于 2019-11-27 18:51:57
问题 I have a GridView bound to a SqlDataSource with a default SelectCommand defined as such: <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataSet" ConnectionString="<%$ ConnectionStrings:MyConn %>" ProviderName="MySql.Data.MySqlClient" SelectCommand="select * from blah blah" /> There are cases where I have to change this query dynamically at runtime, so I do the following: SqlDataSource1.SelectCommand = sql; // 'sql' is the new query GridView1.PageIndex = 0; GridView1