Forms Data Controls :: Unable To Enter Data Into Database
Apr 30, 2010unable to enter data into database
View 4 Repliesunable to enter data into database
View 4 RepliesI have a gridview, I am allowing user to enter HTML data while editing a record in a gridview row. When I am clicking update button then I am getting this message
A potentially dangerous Request.Form value was detected from the client (ctl00$ContentPlaceHolder1$gvCommentDetails$ctl02$ctl04="This is message,This is mark. ...").
as I am using sql data source to update the gridview record.
" SelectCommand=" SELECT c.Id,c.Name, c.message
FROM Table1 c
UpdateCommand=" UPDATE Table1
SET Name = @Name,
message = @message
WHERE Id= @Id">
I have take a datagrid view and now i want to update the records as the database is been normalized i need to enter the multiple rows at once. How you I convert the datagrid to enter the data so that it would be easy for me to update the records?
View 1 Repliescheck the VB behind code for any syntax errors.Unable to add new rows of data to a database using the DataGrid control.Compilation Error message is located at http://cforedu.com:View snap shot images of each line error at http://cforedu.com/snap.pdfThe VB code behind reads (revision 1.3):
[Code]....
I got a table in a formview where i placed lots of textboxes and dropdownlists inside the table because I need these textboxes and dropdownlists on a background image.
the data on textboxes and dropdownlists that are inside the table is unable to be saved into the database when i pressed the "submit" button. Other textboxes and dropdownlists that are not inside the table work fine. Here are the HTML code for the table:
<asp:Table ID="Table1" runat="server" BackImageUrl="~/images/DRAWING.jpg">
I am unable to insert records into the database due to this error:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object
This sentence is highlighted in red:
osdb.Insert_ItemsRecords(txtID.Text, txtItemName.Text, txtItemDesc.Text);
BindGrid(true);
How do i set set the osdb to a valid instance?
I am using gridview with some columns few are :
<asp:templatefield headertext="Title Description" sortexpression="Description">
<itemtemplate>
<asp:Label id="Description" runat="server" Text='<%# Bind("Description")%>'></asp:Label>
</itemtemplate>
<edititemtemplate>
<asp:textbox id="Description" runat="server" CssClass="form-control" text='<%# Bind("Description") %>' />
[Code] ....
Now this AddGridAddBTN Temporarily adds a data row to a grid but won't submit that data to database, however AddGridSubmitBTN Submits the data to DB through foreach loop .
Now my query is i want to provide user a functionality that when he gets focus on Abbreviation Text Box OR Description Box and he after typing some data Press ENTER KEY , This ENTER KEY would provide funcionality as a AddGridAddBTN Button , and when he presses SHIFT + ENTER , It works like AddGridSubmitBTN Button , also i want to make Abbreviation and Description Field to be filled must !
Moral is that :
ENTER KEY WOULD DO : Generate a temporary row with holding previous values as it is actually doing on AddGridAddBTN Button.
SHIFT + ENTER WOULD DO : Enter the whole grid data thorugh foreach loop as it is actually doing on AddGridSubmitBTN Button.
I don't want to refresh my page on enter or shift enter pressing . This grid is binded through SQL DATA SOURCE ...
I have 2 table in database
1-Estate_free Table
2-Black_list Table
in Register.aspx users can insert their information and when click on insertButton it insert their data into Estate_free table
below is code
protected void insertButton_Click1(object sender, ImageClickEventArgs e)
{
SqlCommand _cmd = new SqlCommand("InsertFreeState1", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
[Code].....
in above SP I define that if users tell or Mobile number was in Estate_free ro Black_list table it doesn't insert data into database and show 'You can just register 1 Time' and if there wasn't their mobile or Tell in those table it insert their data into Estate_free table and show 'You have been registered'.
problem is that when I enter data in database with new mobile number it didn't insert data in database and show 'you can just register 1 Time'.
I mean it never insert data in database.
what should i do?
I am unable to create dynamic menu from database. I have made two tables for this work.First table is Menu which stores menu id and its relevant name.
MId Text
------------
1 File
2 Edit
3 View
..
..
Second table is subMenu which stores submenus which will be linked to the menu table with menu id.
SId Text MID
-------------------
1 New 1
2 Open 1
3 Save 1
4 Cut 2
5 Copy 2
the menu should be created dynamically from the database, each menu should be displayed in single row
when we click on a menu the submenus are displayed in rows that in expand & contrast form
how to design & develope this page
i wants to enter data in each cell like without using any button like edit,update button example
i have 4 column and in 2 column already we have value remaining 2 column user should make data entry if the did any wrong entry in the cell , it should fire the error message
I have a detailsview in insert mode. I want to prompt the user to enter data in all fields, if left empty. Could someone please find a few minutes to show me how to do it?
View 2 RepliesI am trying to implement this ..[URL]I have created stored procedure which is working fine. I have changed the database and table name.
In code behind I changed string query = "[GetCustomersPageWise]"; to===> string query = "[GetMsgs]" /*
Which is the correct name of my new stored procedure
*/In repeater code I changed <b><u><span class="name">
<%# Eval("ContactName") %></span></u></b>
to ===> <b><u><span class="name">
<%# Eval("Date") %></span></u></b> /*and so on.
Date is a column name of the table i am using.*/
I have 2 table in database 1-State 2-City and bind DropDownList 1-ddlstate 2-ddlCity from these table and when I select item from ddlsate , according to my selected item from ddlState , ddlcity's Item change I used OnSelectedIndexChanged for ddlstate
problem is: I enter some data in tables with persian Alphabet now when I select some Item from ddlstate that contain these alphabet in persian "ی ،پ،... " it didn't show any Item in ddlcity but when I select item that didn't contain above alphabet it show item in ddlcity correctly why this happen?
i am unavble to update the data in nested data lists in asp.net, if any one have the code
View 3 RepliesI have 2 textbox’s and checkbox list. I want user to either enter text in one of the textbox or select any item from the checkbox list. User has to do only one action i.e. either fill the first textbox or second text box or select any item from the list.
View 1 Repliesi have an application in Vs. C# i have gridview with big data so its not in graphical mode so i want to paging in gridview . is there any command in C# to enter paging in gridview ?
View 5 RepliesI have a grid view with item template ....In the footer template of the gridview i have a button ... On clicking the button a new item template row is created .Wat i need is , by pressing the enter key i need to add new row .... It is already adding new row on button click .... The same should be done on pressing the enter key on the last row of the gridview item template .....
View 2 RepliesI Have one gridview which i show in admin panel and need to allow edit and delete the row.now my problem is when click on edit i need to check that duplicate record not allow to enter and my password is in encrypted formate and i need to show decrypted form in gridview so if admin want to edit password then he can edit it
And at a time of edit gridview can i give option of dropdow to selection instead of text box?
I know how to catch a key pressed, but I don't know how to do that in a gridview to get the the row index and the value of the field. Explanation in the code below (it is going to be more clear I guess) :
[Code]....
In the txtPosition TextBox the user is entering a number and press the Enter key which launch the "HandleAttribute" event as if the client had click on the "imgbtnUp" ImageButton.
I list selections of available items in a gridview and have added a button column for adding items to a cart. Is there a way to add a column where the user can enter the quantity to add?
View 1 Repliesa)i have an gridview, i need to every record show in every rows, but it's show in both column and rows...., how fix this?i use only itemTemplate in this gridview!
b)how i link a field thats show in gridview and pass to a new page(with query string) for show single record....?
(this is like "read more..." link in many news site!!!)
c)in my db is a 'ntext' field,but when that show in Gridview,all enter(Chr13) and whitespace deleted, how fix this?
I am reading data from Excel file using oledbdataadapter and binding to gridview.Every thing working fine.but if the cell is having some text along with bar sysmol ( | ) [Ex : 12345 | 789123] that cell data is not reading from excel file.All fileds in excel sheet is text format only.Some times it's reading correctly & some times it not reading(empty).Is there any problem with bar symbol ( | )
View 1 Repliesi am still stumped with this operation: i am trying to retrieve a GridView selected row data..here is my code.. the commented part that gives me the selectedindex works just fine....but the one giving the selected row cell value does't work and there is no error.. The update operation is done successfully...weired. i need to assigned selected row cells values to variables ..do some calculations and then re-assign the result calculation to cell[9]..
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string s = GridView1.SelectedRow.Cells[5].Text;
TextBox1.Text = s.ToString();
//string s2 = GridView1.SelectedIndex.ToString();
//TextBox1.Text = s2.ToString();
}
i m unable to bind data inside checkbox list. this is my code
protected void dlBreeds_ItemDataBound(object sender, DataListItemEventArgs e)
{
try
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
CheckBoxList cbl = e.Item.FindControl("cblAnimaltype") as CheckBoxList;
if (cbl != null)
{
cbl.DataTextField = DataBinder.Eval(e.Item.DataItem, "BGName").ToString();
cbl.DataValueField = DataBinder.Eval(e.Item.DataItem, "ID").ToString();
}
}
}
catch (Exception ex)
{
pnlStatus.Visible = true;
lblMessage.Text = ex.Message.ToString();
}
}
protected void BindAnimals()
{
//*********************************************************************************
// Purpose : To bind breeds in listbox
// Inputs : Nothing
// Returns : Nothing
//*********************************************************************************
DataSet ds = new DataSet();
try
{
ds = InvertebrateProviders.GetBreedsName_Invertebrate(1);
if (ds.IsInitialized)
{
DataView dv = ds.Tables[0].DefaultView;
dv.RowFilter = "ID<>0";
dlBreeds.DataSource = dv;
dlBreeds.DataBind();
}
}
catch(Exception ex)
{
pnlStatus.Visible = true;
lblMessage.Text = ex.Message.ToString();
}
}
<asp:DataList id="dlBreeds" runat="server" DataKeyField="BGName" OnItemDataBound="dlBreeds_ItemDataBound" RepeatDirection="Vertical">
<ItemTemplate>
<asp:Panel ID="pnbBreed" BorderColor="#7f9db9" Height="129px" Width="220px" ScrollBars="Vertical" BorderWidth="1px"
BorderStyle="solid" runat="server" Visible="true">
<asp:CheckBoxList ID="cblAnimaltype" DataTextField='<%#Eval("BGName") %>' DataValueField='<%#Eval("ID") %>' AutoPostBack="True" runat="server" Height="129px" CellPadding="0" CellSpacing="0"
OnSelectedIndexChanged="cblAnimaltype_SelectedIndexChanged" Width="200px" >
</asp:CheckBoxList></asp:Panel>
<asp:CheckBoxList ID="cblBreeds" Height="90px" Width="200px" runat="server" ></asp:CheckBoxList>
</ItemTemplate>
</asp:DataList>
using vs2005 I have a formview control I added from the data section and within the formview, I aded a table from the Standard section. How can I add a text box to the formview so I can enter a number like 7 to display seven rows with a text box. the data will be saved to the sql table when I click on the Insert link at the bottom of the page.
View 2 Replies