|
error is:
Cannot implicitly convert type 'int' to 'string'
To help you find the cause here is what I have at present:
protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Sources dropdown in gridview...
DropDownList ddlgvSources = (DropDownList)e.Row.FindControl("ddlgvSources");
PopulateSourcesGridView(ddlgvSources);
//ddlSources.SelectedIndex = ddlgvSources.Items.IndexOf(ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString()));
ddlSources.SelectedValue = ddlgvSources.Items.IndexOf(ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString()));
}
//populate the dropdown list of the Sources in the GridView...
private void PopulateSourcesGridView(DropDownList ddl)
{
string strSourceID;
string strName;
int intSources;
DataTable dtSources = clsAccess.SourcesGet();
intSources = dtSources.Rows.Count;
ddl.Items.Clear();
for (int i = 0; i < intSources; i++)
{
strSourceID = dtSources.Rows[i]["SourceID"].ToString();
strName = dtSources.Rows[i]["SourceName"].ToString();
ddl.Items.Add(new ListItem(strName, strSourceID));
}
}
//////////////////////////////////
<EditItemTemplate>
<asp:DropDownList ID="ddlgvSources" runat="server" SelectedValue='<%# Eval("SourceName") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("SourceName") %>'></asp:Label>
</ItemTemplate>
|
|
|
|
|
ddlSources.SelectedValue = ddlgvSources.Items.IndexOf(ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString()));
Replace above line of code with following line
ListItem li= ddlSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString());
li.Selected = true;
|
|
|
|
|
On clicking the edit of the row which fires the event grid_RowEditing(object sender, GridViewEditEventArgs e)
then the grid is repopulated and so on grid.databind the error is:
'ddlgvSources' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Any thoughts?
|
|
|
|
|
this may work
ddlgvSources.ClearSelection()
put this line of code before you are going to select list item
|
|
|
|
|
Not sure what you mean because I click on the edit only without doing any changes and the error occurs just before the repopulation of the grid.
And where do you mean I should put this code exactly please?
|
|
|
|
|
According to me when you are clicking edit of that grid its selecting vlaue in dropdown box again some how so according to me you just clear selection of the dropdown box before going to select for item in it
|
|
|
|
|
Apologies but not sure where exactly in the code you want me to put this...
Anyway, In the grid the cell has a text value and so does the droop down. I would like to match the dropdowntext with the text in the cell of the grid.
So this is what I am doing but the selected text is not selected in the droopdown. Do you see why?
ddlgvSources.SelectedValue = ddlgvSources.Items.IndexOf(ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString())).ToString();
|
|
|
|
|
I am breaking down the result so hoopefully it helps you more:
DataBinder.Eval(e.Row.DataItem, "SourceName").ToString()
returns
"Isor"
ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString())
returns
null
ddlgvSources.Items.IndexOf(ddlgvSources.Items.FindByValue(DataBinder.Eval(e.Row.DataItem, "SourceName").ToString()))
returns
-1
please note that I would like the text "isor" to be selected in the dropdown
|
|
|
|
|
solved by using findbytext.
Thank you
|
|
|
|
|
Hi,
I am unable to retrieve the cell value of the selected row.
The column is set to readonly=true and visible=false
In the grid_rowupdating event
This should be referring to the 2nd coluomn in the grid.
string strValue = ((TextBox)grid.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
The error is:
Specified argument was out of the range of valid values.
Parameter name: index
Any thoughts please?
Thanks
|
|
|
|
|
You've marked it as visible=false so the column won't render and thus will not be available.
You may want to look here, and elsewhere, for some tips and ideas
DataGridDemo[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
solved.
I am using a template and yet it is still invisible which is fine.
Thanks
|
|
|
|
|
hi,
I have managed to put a dropdown control inside a GridView for each row.
How do i populate the dropdownlist control with the required data?
Thanks
modified on Tuesday, January 26, 2010 10:18 AM
|
|
|
|
|
This is solved by using a column template instead.
Thanks
|
|
|
|
|
hELlo,
I have to design the frontend(look and feel) of a website(personal project) before i start implementing it.Can i create website template using photoshop or is their any better tool available for the same.
NOTE:- I am not a designer.
|
|
|
|
|
AndyInUK wrote: before i start implementing
Always a good idea to plan before starting
You can certainly use Photoshop, or similar tools, to create the graphics; however, it is not a web development tool.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You may want to check out Photoshops save for web feature in addition to "Slices". File -> Save for web.
It will generate the HTML too if you want it to, and then you can modify it to suit your back end.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
hi All this is very urgent and very critical problem i have faced and searched alot but did not find any solution any help is very very appriciated.
I am using VS 2008 and in VS 2008 if i design crystal report in landscape its design time envoirnment is fine and when i run it displays ok but when I hit the print button to print the report it prints in portrait.
I have searched a lot but did not find any solution in some forums i get the server side solution i.e
reportObject.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape
but it will not work because i need to print on client printer and this will print from ther server printer.
I hope you peoples will help me.
waiting for you response
|
|
|
|
|
Did you find any answer to the landscape issue? I have the same issue but could not find right solution on google. Everyone says set the PaperOrientation but that doesnt work. Please share if you have found the solution. Thanks!
|
|
|
|
|
Is it free to use Google API for purposes like it's used in codeproject web site - Job Board?
I have an idea to make site with job offers and the location of the jobs on the map.
Thanks for the answers!
|
|
|
|
|
Yes it is free for their map API. I think you are allowed a certain amount of views, after that you may have to pay for it.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
|
Is there a way I can find which site is using Premier Account or not?
|
|
|
|
|
Respected,
Sir, My GridView do not display name in template field
my code as your reference is :
Text='<%# GetClassName(DataBinder.Eval(Container.DataItem,"CLASSID")) %>'
I am calling a function for name by passing ID and display in template field class but it can not work. please help me.
Thanks.
modified on Tuesday, January 26, 2010 5:31 AM
|
|
|
|
|
For this kind of issue i must suggest you use : RowDatabound event of the grid view and do the code
hope below thing work for you
public void sumRows ( Object src, GridViewRowEventArgs e ) {
if ( e.Row.RowType == DataControlRowType.DataRow ) {
TableCellCollection cells = e.Row.Cells;
int priceTotal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, _
"UnitPrice"))
//do code to assign value to columns of the grid
}
}
|
|
|
|