|
I need to pass a variable to the controlid of a ControlParameter so i can tell a Gridview which row the dropdownlist im editing belongs to.
What would be the best moethod for setting the control id?
Thanks.
|
|
|
|
|
Basically, the ControlParameter does not support the DataBinding event so you cannot use a data binding expression to set the ControlID property of the parameter, and your choice is to do this in code. Also, you need to be aware that the ControlID property needs to be updated before it is used to populate the value, if it happens after then you'll get an error as the specified control is not found. Normally, the ControlParameter uses its ControlID property to evaluate the parameter value in the overridable Evaluate method which occurs in the LoadComplete event of the Page instance. So you can put your code to update the ControlID in the events (of the data source control or the Page instance) that happens before the Page_LoadComplete and of cource after the data source control is built. For example, you can use the Load event of the data source control:
protected void SqlDataSource1_Load(object sender, EventArgs e)
{
ControlParameter para = SqlDataSource1.UpdateParameters[0] as ControlParameter;
para.ControlID = "GridView1$ctl0" + (GridView1.EditIndex + 2) + "$DropDownList1";
}
where the EditIndex property of the GridView control will give you the index of the row being edited, this is a zero-based value, however the index used in the UniqueID of the dropdownlist is a one-based value and it is counted from the header row. Therefore, you have to add 2 to the EditIndex to get the correct number used in the UniqueID.
|
|
|
|
|
Hi,
I have used below code (asp.net 2.0) to Save the Table (GridView 'GrdDynamic') in Webpage into a microsoft WORD file(.doc). But the below code Writes the Entire Web Page into Word file. How can I Save only the Portion (few Controls) of the page?
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application/msword"
Response.BufferOutput = False
'Response.Charset = ""
'tw.WriteLine("Weekly Report")
GrdDynamic.RenderControl(tw)
'Response.AppendHeader("Content-Disposition", "Attachment; Filename=demo.doc")
Me.EnableViewState = False
Response.Write(sw.ToString())
Dim fileToDownload As FileInfo = New FileInfo(strFileName)
Response.Flush()
Response.WriteFile(fileToDownload.FullName)
Response.End()
Regards,
Jay
|
|
|
|
|
protected void GV_account_RowDataBound(object sender, GridViewRowEventArgs e)<br />
{<br />
DataSet ds =new DataSet();<br />
ds=(DataSet)Session["ds"];<br />
Label lbl_title=new Label();<br />
lbl_title = (Label)e.Row.FindControl("lbl_title")<br />
lbl_title.Text =Convert.ToString(ds.Tables[0].Rows[0]["sex"]);<br />
<br />
'<br />
'<br />
'<br />
'<br />
'<br />
'<br />
'<br />
'<br />
<br />
<br />
}
Object reference not set to an instance of an object.
error line:--lbl_title.Text = Convert.ToString(ds.Tables[0].Rows[0]["sex"]);
Pathan
|
|
|
|
|
imrankhanpathan wrote: Label lbl_title=new Label();
This line is pointless it has no effect other than to create an object that is never used. It should be merged next line in your code which retrieves the actual Label that you want.
imrankhanpathan wrote: lbl_title.Text = Convert.ToString(ds.Tables[0].Rows[0]["sex"]);
There are many possibilities here
* lbl_title is null
* ds is null
These are also possibilities, but they'll probably give a different exception:
* ds.Tables[0] is null (i.e. there are no tables)
* ds.Tables[0].Rows[0] is null (i.e. the table has no rows)
* ds.Tables[0].Rows[0]["sex"] is null (i.e. There is no column called "sex")
|
|
|
|
|
use break point itis good tool, to trace errors... press F11 to trace line by line... u will autometcally get whats the problem...
|
|
|
|
|
blue_arc wrote: use break point itis good tool, to trace errors... press F11 to trace line by line... u will autometcally get whats the problem...
Good advice, but when he has big long lines like this
lbl_title.Text =Convert.ToString(ds.Tables[0].Rows[0]["sex"]); then breakpoints become less useful. It is better to refactor the line out into several lines like this
DataTable table = ds.Tables[0];
DataRow row = table.Rows[0];
object sexColumnValue = row["sex"];
string text = sexColumnValue.ToString();
lbl_title.Text = text;
|
|
|
|
|
Colin Angus Mackay wrote: then breakpoints become less useful.
True, but the quick watch window will do partial evaluations - i.e. highlight ds.Tables, QW, and it will show the details of the tables collection. You can then work your way down the command till one returns an error in QW
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
instead
lbl_title.Text = Convert.ToString(ds.Tables[0].Rows[0]["sex"]);
use this way
lbl_title.Text =ds.Tables[0].Rows[0]["sex"].ToString();
|
|
|
|
|
imrankhanpathan wrote: lbl_title.Text =Convert.ToString(ds.Tables[0].Rows[0]["sex"]);
Set a breakpoint in the quoted line. When the breakpoint hits quickwatch on the values of each.
1) Either Tables[0] or Rows[0] is evaluated to null. I don't think ds can be null since it is cast from Session object and if Session is null, it would thrown exception two lines above (InvalidCastException)
2) new Label does not serve any purpose unless a controls.Add is called to add itself to the page. The other way round, have <asp:label in="" the="" aspx="" page="" and="" just="" declare="" label="" <code="">protected Label lblId
|
|
|
|
|
Vasudevan Deepak Kumar wrote: I don't think ds can be null since it is cast from Session object and if Session is null, it would thrown exception two lines above (InvalidCastException)
Incorrect, null can be cast successfully to another object.
For example, try this in a console application:
object o = null;
string s = (string)o;
Console.WriteLine("String is null: {0}", s == null);
Console.ReadLine();
|
|
|
|
|
Thank you. It was enlightening.
But I have encountered the above piquant situation with DbNull.Value casting too. Could'nt get an immediate standalone snapshot example though.
Thanks for the poiner anyway.
|
|
|
|
|
Since the birth of my second child ["sex"] has always been an invalid object...
Regards
*********************************************
|
|
|
|
|
Hi
I have various web pages that perform lengthy operations. I use asynchronous calls and callbacks, and update the screen with progress. All works perfectly on my local box using teh development server. but...when I migrate to the IIS release server, the asynchronous elements all stop working. Ive got asnych code in codebehind and in C# webservices, and locally, they all work. On IIS they don't.
So, the question is - do I have to configure IIS in anyway to allow me to do asynchronous calls?
Desparate.
Regards
*********************************************
|
|
|
|
|
if u r using mozilla or firre fox then u will not able to work.. ur problem is correct in this case..
because in mozilla cross domain async call of data is not allowed....
or may be ur web sevice is not published on new server....
Ravi Kant Srivastava
(System Analyst)
HandsOn Technology and Engineering
(Gurgaon India)
|
|
|
|
|
IE6. But problem is server side, not client side. Webservice is published, and also failing from non webservice pages, ie CodeBehind.
Regards
Angel
*********************************************
|
|
|
|
|
Doh
Permissions!
Running locally, on my dev box, I had permissions set for everything. Not so on the IIS box. Sorted!!
Regards
Angel
*********************************************
|
|
|
|
|
Hi All, What is difference between dotnet nuke and Microsoft Solution Framework.....???
i m confuse
Thanks
Sajjad
|
|
|
|
|
imshally81 wrote: What is difference between dotnet nuke and Microsoft Solution Framework.....???
They are totally different things. They are not comparible.
DotNetNuke is open source web portal software. Microsoft Solutions Framework (MSF) is a set of business processes for developing software.
|
|
|
|
|
|
imshally81 wrote: u mean, MSF like RUP ???
Good grief! MSF is much better than RUP.
|
|
|
|
|
While opening new Project in ASP.net there is select Control with options
as 1] FileSystem 2] HTTP 3] FTP . What these options are and their criteria to select . Though at the momement I am using Filesystem
Navneet Hegde
progarm2Develop & Develop2program
|
|
|
|
|
In the new ASP.NET 2.0 there are two ways to host an application. First way is to host it on IIS and second is to host it on the built-in web server bundled by default with VS.NET 2005. Selecting File System will create the web application anywhere on your hard disk and will use the .NET's web server. Selecting the HTTP will create it in the inetpub/wwwroot folder like the older version of ASP.NET.
As far as ftp is concerned .NET 2005 now enables you to create and open a project from anywhere on your network.
Bill, do I deserve a job now?
Happy Coding
Aleem
|
|
|
|
|
Very Much thanks for your exact and terse answer. Looking for many such transaction across CodeProject.
Happy Coding,
Navneet Hegde
develop2Program program2develop
|
|
|
|
|
Much satisfaction from babelfish using did get I.
|
|
|
|