|
In my from i use grid view .In that i add rows and values dynamically on button click.when i click the submit button all the row values must be insert in to database how can i do that.In grid i didnt use any template.I just add values in that.how can i find each row vaues and save to database.
|
|
|
|
|
Hi all,
I have a gridview that when i select a row of gridview a detailview comes that i can edit or delete or insert a record in database.
but this changes not be shown in my gridview that time.
i should again run my program that these changes be shown in my gridview.
How i can update GridView in web page when i edit or delete or insert a record in database with detailview without re run?
Thank you,
Hoda
|
|
|
|
|
You should bind your data grid to it's data source in prerender, not in page load. Then, it will occur after any event handlers, and you should see the results.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all...
I think my subject line not dat much clear...
Here is My Requirement:
*I hav windows project ..it displays ads in the masterform.. and also
*I hav webproject in dat user is going to add their adds(i mean de can register their ads in dis webproject)
Actually Client uses the Windows project.. when client is connected to internet and opens our website(our webproject) den we have to upload our ads which r registered in our webproject into ClientSystem(Window project) in place of ads(In masterform we r providing place for Displaying ads..AdRotator )..
How can i achieve this.. how can i solve dis by WebServices/WinodwsServices...
Plz..Help me in dis issue...I need ur suggestions....
Thanks in Advance.
Thanks&Regards,
kvsekhar
|
|
|
|
|
Please don't be doing de cross post in de different forums. Dat be annoying.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hi, As my requirement is i want to bind data to the dropdownlist in the gridview control. when iam doing this iam getting an error. "Cannot implicit convert Type 'string' to 'int'", "Only assignment, call, increment, decrement, and new object expressions can be used as a statement",and "Cannot apply indexing with [] to an expression of type 'method group'". Please help me...My code is as follows..
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = GetDataSet().Tables[0];
GridView1.DataBind();
}
private DataSet GetDataSet()
{
string connectionString = "user id=sa;password=victory;database=Northwind;server=INDUS-SERVER";
string query = "SELECT p.CategoryID, p.ProductID, p.ProductName, c.CategoryID, c.CategoryName from Products p,Categories c where p.CategoryID=c.CategoryID and c.CategoryID<2";
SqlConnection newConnection = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter(query, newConnection);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataTable myDataTable = new DataTable();
DataColumn productIDColumn = new DataColumn("ProductID");
DataColumn productNameColumn = new DataColumn("ProductName");
myDataTable.Columns.Add(productIDColumn);
myDataTable.Columns.Add(productNameColumn);
DataSet ds = new DataSet();
ds = GetDataSet();
int categoryID = 0;
string exp = string.Empty;
if (e.Row.RowType == DataControlRowType.DataRow)
{
categoryID = Int32.Parse(e.Row.Cells[0].Text);
exp = "CategoryID=" + categoryID;
DropDownList ddl = (DropDownList)e.Row.FindControl("DropDownList1");
DataRow[] rows = ds.Tables[0].Select(exp);
foreach(DataRow roe in rows)
{
DataRow newRow = myDataTable.NewRow();
newRow["ProductID"] = rows["ProductID"];
newRow["ProductName"] = rows["ProductName"];
myDataTable.Rows.Add[newRow];
}
ddl.DataSource = myDataTable;
ddl.DataValueField = "ProductName";
ddl.DataValueField = "ProductID";
ddl.DataBind();
}
}
}
|
|
|
|
|
Can you tell me on which line your getting the Error ?
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
Iam getting the error with the following lines...
DataRow newRow = myDataTable.NewRow();
newRow["ProductID"] = rows["ProductID"];
newRow["ProductName"] = rows["ProductName"];
myDataTable.Rows.Add[newRow];
|
|
|
|
|
I noticed that the Column "ProductID" (DataColumn productIDColumn = new DataColumn("ProductID") did not specify the Data type.
I think your data base returning ProductID as int type.
So you can resolve this prob lem in two way
(1) newRow["ProductID"] = rows["ProductID"].ToString();
OR
(2)Also specify the Data type as int, When you are creating the column
DataColumn productIDColumn = new DataColumn("ProductID")
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
Still iam getting the same error even if i do the things whatever you said..please any further suggestions..
|
|
|
|
|
Even i tried your solution then also iam getting the same error..Please any further suggestions...
|
|
|
|
|
Can you post here modified code which i have suggested to you ?
Mark as bold where you are still getting the problem and also post error messages.
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
Hi,
I am using RegisterStartupScript in a user control but it is not running the code.
Can you do this from a user control?
msg = "Invalid date entered for 'to' field."
script = "<script>"
script += "alert(""" & msg & """);"
script += "</script>"
Me.Page.RegisterStartupScript("script", script)
rotsey
|
|
|
|
|
Try this One:
msg = "Invalid date entered for 'to' field."
script = ""
script += <b>"alert('" & msg & "');"</b>
script += ""
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
|
hi want set some values in web.config, so that i can access it in all pages
say, color=red
how can i set that in webconfig and access in any of my webpage
|
|
|
|
|
use Appsetting in the webConfig
<appSettings>
<add key="MHASSANF" value="Programmer"/>
</appSettings>
|
|
|
|
|
how to access it in every webpage
|
|
|
|
|
|
<asp:gridview id="GridView1" runat="server" width="225px" gridlines="None" autogeneratecolumns="False" onrowcommand="GridView1_RowCommand" ><br="" mode="hold"> <columns>
<asp:templatefield>
<itemtemplate>
<asp:image id="Image1" imageurl="<%# Eval(" imagee")%"="">' runat="server" Width="20" Height="12"/>;
<asp:linkbutton id="lblink1" runat="server" font-overline="false" text="<%# Eval(" category")%&"="">' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "category") %>;' Font-Size="10" Font-Names="Arial" CommandName="Click><asp:linkbutton>>
<asp:bulletedlist bulletstyle="Square" id="bullet" runat="server" datatextfield="subcategory" font-bold="true" font-names="Arial" font-size="12px">&
i want to display the bulletlist after the link button..
but i store the subcategory in one table and category will be stored in another table pls help me...
|
|
|
|
|
Where u want to display bulletlist ?
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
if i click any one of the category the bulletlist of the sub category display below the category.....
|
|
|
|
|
(1) Use commandName
CommandName="CategoryClick instead of Click
(2)Set Gridview attribute:
<asp:gridview id="CustomersGridView"
onrowcommand="CustomersGridView_RowCommand".....
(3)Add below method in Code behind file:
void CustomersGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName=="CategoryClick")
{
string Category = e.CommandArgument;
}
}
Parwej Ahamad
R & D with IIS 5.0/6.0
|
|
|
|
|
but i used two table ... one table used for store category and another table used for store subcategory
That only i cannot display the record in one gridview
|
|
|
|