I've removed that "No record" message inside EmptyDataTemplate
Why do you remove the EmptyDataTemplate? If you remove this, I'm afraid I cannot do inserting without any data contents bound to the GridView. So you should keep that.
wmec
Please note that there is a Formview within that. But why do I get this?
Why do you put a FormView inside the GridView?
I mean you can just use EmptyDataTemplate to cope with the problem.
and I have not removed EmptyDataTemplate. Please refer to the original reply from Oned to this thread that he provided the way to have a formview inside EmptyDataTemplate.
can you advise why the way suggested by Oned does not work as expected, and I am still getting this?
Server Error in '/app2' Application.
--------------------------------------------------------------------------------
Format of the initialization string does not conform to specification starting at index 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
It seems that your problem is a little complicated. So it would be better if you can submit your whole proj with your data contents (by mocking a project and submit onto SkyDrive).
I'll contact a senior group member to contact with you;)
Thanks a lot. My current app is not having sensible data inside but is having the mentioned Gridview/formview there. CAn I send it to your email for you to pass it?
Thanks a lot. My current app is not having sensible data inside but is having the mentioned Gridview/formview there. CAn I send it to your email for you to pass it?
Please directly submit this on SkyDrive.
If anything urgent, please write down a text file called readme.txt inside your package.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: No prompt for data input
Feb 04, 2013 01:31 AM|LINK
Why do you remove the EmptyDataTemplate? If you remove this, I'm afraid I cannot do inserting without any data contents bound to the GridView. So you should keep that.
Why do you put a FormView inside the GridView?
I mean you can just use EmptyDataTemplate to cope with the problem.
Please see the sample:
http://www.dotnetfunda.com/articles/article180.aspx
wmec
Contributor
6195 Points
3214 Posts
Re: No prompt for data input
Feb 04, 2013 01:47 AM|LINK
I've only removed this message
No Record Found
and I have not removed EmptyDataTemplate. Please refer to the original reply from Oned to this thread that he provided the way to have a formview inside EmptyDataTemplate.
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: No prompt for data input
Feb 04, 2013 01:50 AM|LINK
so have you put several TextBoxes inside the EmptyDataTemplate?
Don't please put FormView, a FormView without Data source cannot be shown, either.
Please follow my sample above carefully;)
wmec
Contributor
6195 Points
3214 Posts
Re: No prompt for data input
Feb 04, 2013 02:28 AM|LINK
Hi,
I have datasource inside Gridview and Formview.
<asp:GridView ID="gv2" runat="server" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="rec_id" DataSourceID="SqlDataSource2"
ondatabound="gv2_DataBound" Width="232px" onrowcommand="gv2_RowCommand" BorderStyle="Inset">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowSelectButton="True" />
<asp:BoundField DataField="rec_id" HeaderText="rec_id" InsertVisible="False"
ReadOnly="True" SortExpression="rec_id" />
<asp:BoundField DataField="user_id" HeaderText="user_id"
SortExpression="user_id" />
<asp:BoundField DataField="int_desc" HeaderText="Description"
SortExpression="int_desc" />
<asp:BoundField DataField="change_date" HeaderText="Edit On"
SortExpression="change_date" />
</Columns>
<EmptyDataTemplate>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="rec_id"
DataSourceID="SqlDataSource1" oniteminserted="FormView1_ItemInserted">
<EditItemTemplate>
rec_id:
<asp:Label ID="rec_idLabel1" runat="server" Text='<%# Eval("rec_id") %>' />
<br />
user_id:
<asp:TextBox ID="user_idTextBox" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:TextBox ID="int_descTextBox" runat="server"
Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:TextBox ID="change_dateTextBox" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
user_id:
<asp:TextBox ID="user_idTextBox" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:TextBox ID="int_descTextBox" runat="server"
Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:TextBox ID="change_dateTextBox" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
rec_id:
<asp:Label ID="rec_idLabel" runat="server" Text='<%# Eval("rec_id") %>' />
<br />
user_id:
<asp:Label ID="user_idLabel" runat="server" Text='<%# Bind("user_id") %>' />
<br />
int_desc:
<asp:Label ID="int_descLabel" runat="server" Text='<%# Bind("int_desc") %>' />
<br />
change_date:
<asp:Label ID="change_dateLabel" runat="server"
Text='<%# Bind("change_date") %>' />
<br />
<asp:LinkButton ID="EditButton" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" />
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False"
CommandName="New" Text="New" />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
DeleteCommand="DELETE FROM [tab3] WHERE [rec_id] = @rec_id"
InsertCommand="INSERT INTO [tab3] ([user_id], [int_desc], [change_date]) VALUES (@user_id, @int_desc, @change_date)"
SelectCommand="SELECT * FROM [tab3]"
UpdateCommand="UPDATE [tab3] SET [user_id] = @user_id, [int_desc] = @int_desc, [change_date] = @change_date WHERE [rec_id] = @rec_id">
<DeleteParameters>
<asp:Parameter Name="rec_id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
<asp:Parameter Name="rec_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Mssqlconn2 %>"
DeleteCommand="DELETE FROM [tab3] WHERE [rec_id] = @rec_id"
InsertCommand="INSERT INTO [tab3] ([user_id], [int_desc], [change_date]) VALUES (@user_id, @int_desc, @change_date)"
SelectCommand="SELECT * FROM [tab3]"
UpdateCommand="UPDATE [tab3] SET [user_id] = @user_id, [int_desc] = @int_desc, [change_date] = @change_date WHERE [rec_id] = @rec_id">
<DeleteParameters>
<asp:Parameter Name="rec_id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="user_id" Type="Int32" />
<asp:Parameter Name="int_desc" Type="String" />
<asp:Parameter Name="change_date" Type="DateTime" />
<asp:Parameter Name="rec_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
...
Here are the events
protected void Page_Load(object sender, EventArgs e)
{
tb_join_dt.Text = DateTime.Now.GetDateTimeFormats('d')[0];
}
protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
{
gv2.DataBind();
}
can you advise why the way suggested by Oned does not work as expected, and I am still getting this?
Server Error in '/app2' Application.
--------------------------------------------------------------------------------
Format of the initialization string does not conform to specification starting at index 0.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Format of the initialization string does not conform to specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +6713793
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +253
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +134
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +103
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +35
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +294
System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) +60
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +89
System.Web.UI.WebControls.SqlDataSource.CreateConnection(String connectionString) +49
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +209
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +28
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +313
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +146
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +192
System.Web.UI.Control.EnsureChildControls() +189
System.Web.UI.Control.PreRenderRecursiveInternal() +60
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Control.PreRenderRecursiveInternal() +222
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4297
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18034
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: No prompt for data input
Feb 04, 2013 02:41 AM|LINK
Hi wmec again,
It seems that your problem is a little complicated. So it would be better if you can submit your whole proj with your data contents (by mocking a project and submit onto SkyDrive).
I'll contact a senior group member to contact with you;)
wmec
Contributor
6195 Points
3214 Posts
Re: No prompt for data input
Feb 04, 2013 02:46 AM|LINK
Thanks a lot. My current app is not having sensible data inside but is having the mentioned Gridview/formview there. CAn I send it to your email for you to pass it?
HuaMin Chen
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: No prompt for data input
Feb 04, 2013 02:48 AM|LINK
Please directly submit this on SkyDrive.
If anything urgent, please write down a text file called readme.txt inside your package.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: No prompt for data input
Feb 04, 2013 03:59 AM|LINK
Hi again,
I've forwarded your attached thing to an analyzing group, and maybe they will give you some tips after several days.
Please be patient because they are also very busy analyzing other customers' issues;)
Sorry for inconveniences.
css-chlukito
Member
376 Points
48 Posts
Re: No prompt for data input
Feb 04, 2013 07:46 AM|LINK
Hi wmec,
I reply here based on your first post.
You can try another way as showed on below links:
- http://www.codeproject.com/Articles/12291/ASP-NET-GridView-Add-a-new-record
- http://www.codeproject.com/Articles/16036/GridView-with-insert-line
I haven't try your method to attach dummy DataTable but I tried the solution on first link and it works nicely. Hope can work for you too
Please 'Mark as Answer' if this post helps you.
wmec
Contributor
6195 Points
3214 Posts
Re: No prompt for data input
Feb 04, 2013 08:14 AM|LINK
Thanks. Do you have any ideas why I encounter the problem by my codes?
HuaMin Chen