|
What is the Exception/Message?
|
|
|
|
|
Hi!
I have two gridview that are displaying sql queryes there is two collums and i'm comparing theys two girdview's and i need to display the differences between gridview's on third gridview this gridview has two collums calld 'name' 'amount'. So how i can add rows onthe third girdview on code.
|
|
|
|
|
I would make a DataTable with two columns (name and amount) and put my differences in this table. Then simply set the third gridview's datasource to this new table.
|
|
|
|
|
Thanks for the answer, but i have been trying that and not getting it working. here is my code where i'm doing wrong??
DataTable datatable = new DataTable();
DataColumn column;
// Create new DataColumn, set DataType, ColumnName
// and add to DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.String");
column.ColumnName = "Nimike";
datatable.Columns.Add(column);
// Create second column.
column = new DataColumn();
column.DataType = Type.GetType("System.String");
column.ColumnName = "kpl";
datatable.Columns.Add(column);
DataRow dr = datatable.NewRow();
dr["Nimike"] = "Scott";
dr["kpl"] = "25";
datatable.Rows.Add(dr);
dr = datatable.NewRow();
dr["Nimike"] = "Scott";
dr["kpl"] = "25";
datatable.Rows.Add(dr);
dr = datatable.NewRow();
dr["Nimike"] = "Scott";
dr["kpl"] = "25";
datatable.Rows.Add(dr);
dr = datatable.NewRow();
dr["Nimike"] = "Scott";
dr["kpl"] = "25";
datatable.Rows.Add(dr);
gvErot12.DataSource = datatable;
gvErot12.DataBind();
I know that the answer is simple but I cant get it working the gridview is empty but in gvErot12->Rows->Count is 4 but in the gridview is empty.
The code above is only example for the code that I'm using.
Thx
|
|
|
|
|
I dont in C# but in VB u need to declare the Datatable as shared.It might be static in C#.
|
|
|
|
|
Like the guy who posted before me, I also code in VB. So I'm not sure if this is a problem at all, but in VB you can't declare a column, add it to a table, and then use it to create another column and add it to the table. You have to create two instances of a column and add them separately. The same thing goes with the datarow object.
Where are you putting this code? Is it in the PageLoad event?
I would suggest putting a break point in and actually looking at the datatable to make sure it looks the way you want it to. This will narrow it down to find out if the problem is with setting up the datatable or with actually binding the data to the grid.
Sorry I couldn't be of more help.
|
|
|
|
|
Thanks for your help I find the resolution for the problem. I needet to this
gvErot12 = generateBoundField(datatable, gvErot12);
private GridView generateBoundField(DataTable dt,GridView gv)
{
//Iterate through the columns of the datatable to set the data bound field dynamically.
foreach (DataColumn col in dt.Columns)
{
//Declare the bound field and allocate memory for the bound field.
BoundField bfield = new BoundField();
//Initalize the DataField value.
bfield.DataField = col.ColumnName;
//Initialize the HeaderText field value.
bfield.HeaderText = col.ColumnName;
//Add the newly created bound field to the GridView.
gv.Columns.Add(bfield);
}
return gv;
}
this returns the gridview back to the main program and there
gvErot12.DataSource = datatable;
gvErot12.DataBind();
thanks for quideance!!!!!!!
|
|
|
|
|
hi all,
How can we load an Image from SQl database into Imagebox. I tried but didn't get the solution. any body can send solution ,with code if possible.
Imagebox is not having property IMAGE.
Thanking you.
Rajeshwar Reddy
|
|
|
|
|
|
|
hi i am currently reading a book "asp.net2 for dummys" inside that book they mention of how to create a sql express database within asp.net2 however i was just wondering if i could create a sql database NOT on the asp.net2 but on SQL Server Management Studio Express and import the database over is it possible pls tell me thx
|
|
|
|
|
Right click Databases then New Databases
or
run a query using create database
Grady Booch: I told Google to their face...what you need is some serious adult supervision. (2007 Turing lecture)
http:\\www.frankkerrigan.com
|
|
|
|
|
|
hi this is wat the books says:
It uses the supplied SQL membership provider to manage the user database.
If you want to extend the application so that it tracks additional
data besides the user name, password, and the secret question and
answer, or if you want to use your own database to store the member
information, you can code your own provider. For most applications,
however, the supplied provider should be adequate.
however i would like to connect it to my own sql membership provider anyone know what i should change?
|
|
|
|
|
i want to disaply edit button in last column in grid
how can i do that
i am binding grid at run time
|
|
|
|
|
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="editButton" runat="server" OnClientClick="functioneditbutton();"
CommandArgument='<%#Eval("intNewsDetailid") %>' Text="Edit" CommandName="editbutton" /></ItemTemplate>
</asp:TemplateField>
|
|
|
|
|
not working what u ahve given???
|
|
|
|
|
tell me what problem you had ?
|
|
|
|
|
I want to pass two values in response.redirect(). How to do it i am able to pass one variable.
Mohinder Singh
|
|
|
|
|
Response.Redirect("EditNews.aspx?newsid="+intnewsdetailid+"&newsdetail="+chnewsdetail+""
|
|
|
|
|
yes...you can create a struct or an object that contain these 2 values...then put it into session
<< >>
|
|
|
|
|
I really don't know what's wrong with my dropdownlist,they can't display the values in the control.Have connected my application in to the database and entered the values into the fields,please check my code and tell me what might be the problem
**********
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack = False Then
LoadClientSite()
End If
End Sub
*******
Private Sub LoadClientSite()
Dim ds As New Data.DataSet
Dim objdata As Businesslayer.ClientSite = New Businesslayer.ClientSite
ds = objdata.GetUsers
cmbClientSite.DataSource = ds
cmbClientSite.DataBind()
cmbClientSite.Items.Add(New ListItem("Select Client Site", ""))
cmbClientSite.Items.Item(cmbClientSite.Items.Count - 1).Selected = True
End Sub
*******
My class
Public Function GetClientSite() As Data.DataSet
Dim strSQL As String
Dim obj As Datalayer.Database = New Datalayer.Database
strSQL = "Select Client_id,Client_site from ClientSite(nolock) "
GetClientSite = obj.GetDataSet(strSQL)
obj.Close()
Exit Function
End Function
**********
CONTROL-PROPERTY
DataTextField=ClientSite
DataValueFielld_ClientSite_Id
Ola m
|
|
|
|
|
please see your code...
ds = objdata.GetUsers
are you calling the write function??? I think its a silly mistake...
Live life to the fullest
|
|
|
|
|
can you please tell me what might be the problem ,because when i try to run it,it shows that there is a problem with that statement....
Thank you in advance
oga m
|
|
|
|
|
Oga M wrote: ds = objdata.GetUsers
You are calling function GetUsers... but you have function called as 'GetClientSite()'
Oga M wrote: Public Function GetClientSite() As Data.DataSet
Which is correct ??? Atleast both function name should be same.
Harini
|
|
|
|